Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Support querying Iceberg tables that have been REPLACE PARTITION FIELD #37452

Merged
merged 7 commits into from
Jan 3, 2024

Conversation

lipenglin
Copy link
Contributor

@lipenglin lipenglin commented Dec 20, 2023

Why I'm doing:

spark-sql>
CREATE TABLE hive_prod.testdb.sample (id bigint, data string, category string)
USING iceberg PARTITIONED BY (category);
ALTER TABLE hive_prod.testdb.sample REPLACE PARTITION FIELD category with category AS category_111;
INSERT INTO hive_prod.testdb.sample VALUES (1, 'a', 'A'), (2, 'b', 'B'), (3, 'c', 'C');
spark-sql> select * from hive_prod.testdb.sample;
2       b       B
3       c       C
1       a       A
Time taken: 0.437 seconds, Fetched 3 row(s)
impala> select * from sample;
+----+------+----------+
| id | data | category |
+----+------+----------+
| 3  | c    | C        |
| 1  | a    | A        |
| 2  | b    | B        |
+----+------+----------+
sr:
MySQL [testdb]> select * from sample;
ERROR 1064 (HY000): Cannot invoke "com.starrocks.catalog.Column.getName()" because "x" is null

What I'm doing:

Iceberg tables field.name may not necessarily be partition-spec.field.name for identity Partition Transforms, field.name should be identified using partition-spec.field.source-id in schema.

Fixes #issue

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.2
    • 3.1
    • 3.0
    • 2.5

…PARTITION FIELD

Signed-off-by: LPL <lipenglin@apache.org>
@lipenglin lipenglin changed the title [Enhancement] Support querying Iceberg tables that have been REPLACE … [Enhancement] Support querying Iceberg tables that have been REPLACE PARTITION FIELD Dec 20, 2023
@github-actions github-actions bot added the 3.2 label Dec 20, 2023
Comment on lines 798 to 799
public static String getPartitionSourceName(Schema schema, PartitionField partition) {
return schema.findColumnName(partition.sourceId());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you comment here to explain the difference from PartitionField.name() and elaborate on when to use which?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for comments!

Signed-off-by: LPL <lipenglin@apache.org>
Signed-off-by: LPL <lipenglin@apache.org>
* - https://iceberg.apache.org/spec/#partition-specs<br>
* - https://iceberg.apache.org/spec/#partition-transforms
*/
public static String getPartitionSourceName(Schema schema, PartitionField partition) {
Copy link
Contributor

@Youngwb Youngwb Dec 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function could put at IcebergTable, there is no need to be a static utils

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Signed-off-by: LPL <lipenglin@apache.org>
Signed-off-by: LPL <lipenglin@apache.org>
Copy link

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

1 New issue
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

[FE Incremental Coverage Report]

pass : 5 / 5 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/connector/iceberg/IcebergMetadata.java 2 2 100.00% []
🔵 com/starrocks/catalog/IcebergTable.java 3 3 100.00% []

Copy link

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

* - https://iceberg.apache.org/spec/#partition-transforms
*/
public String getPartitionSourceName(Schema schema, PartitionField partition) {
return schema.findColumnName(partition.sourceId());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM,We may refactor this part after fully supporting the transformed partition.

@Youngwb Youngwb merged commit 582c371 into StarRocks:main Jan 3, 2024
42 checks passed
Copy link

github-actions bot commented Jan 3, 2024

@Mergifyio backport branch-3.2

@github-actions github-actions bot removed the 3.2 label Jan 3, 2024
Copy link
Contributor

mergify bot commented Jan 3, 2024

backport branch-3.2

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Jan 3, 2024
…PARTITION FIELD (#37452)

Signed-off-by: LPL <lipenglin@apache.org>
(cherry picked from commit 582c371)
lipenglin added a commit to lipenglin/starrocks that referenced this pull request Jan 9, 2024
…PARTITION FIELD (StarRocks#37452)

Signed-off-by: LPL <lipenglin@apache.org>
wanpengfei-git pushed a commit that referenced this pull request Jan 15, 2024
…PARTITION FIELD (backport #37452) (#38316)

Co-authored-by: LPL <lipenglin@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants