Skip to content

[Enhancement] Support analyze iceberg table with partition transform #39907

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

Merged
merged 4 commits into from
Jan 30, 2024

Conversation

Youngwb
Copy link
Contributor

@Youngwb Youngwb commented Jan 24, 2024

Why I'm doing:
Iceberg table with partition transform would not work normally
What I'm doing:
iceberg has partition transform like year/month/day/hour, so we need to map partition column to range with year/month/day/hour, eg. ts is partition column and type is date with year transform,
origin predicate is ts = '2022',
but ts with year partition transform needs predicate
ts >= '2022-01-01' and ts < '2023-01-01';
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

@Youngwb Youngwb requested review from a team as code owners January 24, 2024 13:23
@github-actions github-actions bot added the 3.2 label Jan 24, 2024
return null;
}


public long nextPartitionId() {
return partitionIdGen.getAndIncrement();
}
Copy link

Choose a reason for hiding this comment

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

The most risky bug in this code is:
Potential null pointer access in the call to getNativeTable().spec() if getNativeTable() returns null.

You can modify the code like this:

public PartitionField getPartitionField(String partitionColumnName) {
    NativeTable nativeTable = getNativeTable();
    if (nativeTable == null) {
        return null; // or throw an exception depending on expected behavior
    }
    List<PartitionField> allPartitionFields = nativeTable.spec().fields();
    Schema schema = nativeTable.schema();
    for (PartitionField field : allPartitionFields) {
        if (getPartitionSourceName(schema, field).equalsIgnoreCase(partitionColumnName)) {
            return field;
        }
    }
    return null;
}

Signed-off-by: Youngwb <[email protected]>
Signed-off-by: Youngwb <[email protected]>
Signed-off-by: Youngwb <[email protected]>
Copy link

Copy link

[FE Incremental Coverage Report]

pass : 45 / 53 (84.91%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/catalog/IcebergTable.java 5 7 71.43% [180, 181]
🔵 com/starrocks/statistic/ExternalFullStatisticsCollectJob.java 13 16 81.25% [211, 212, 213]
🔵 com/starrocks/connector/iceberg/IcebergPartitionUtils.java 26 29 89.66% [259, 305, 306]
🔵 com/starrocks/connector/iceberg/IcebergPartitionTransform.java 1 1 100.00% []

Copy link

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

@Youngwb Youngwb merged commit 1dc523c into StarRocks:main Jan 30, 2024
@Youngwb Youngwb deleted the analyze_transform branch January 30, 2024 08:51
Copy link

@Mergifyio backport branch-3.2

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

mergify bot commented Jan 30, 2024

backport branch-3.2

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Jan 30, 2024
wanpengfei-git pushed a commit that referenced this pull request Jan 30, 2024
liubotao pushed a commit to liubotao/starrocks that referenced this pull request Jan 31, 2024
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