Skip to content

[#4757]feat(trino-connector): Support more partition and sort order features of the Iceberg catalog#4925

Merged
diqiu50 merged 9 commits intoapache:mainfrom
diqiu50:iceberg-expr
Oct 22, 2024
Merged

[#4757]feat(trino-connector): Support more partition and sort order features of the Iceberg catalog#4925
diqiu50 merged 9 commits intoapache:mainfrom
diqiu50:iceberg-expr

Conversation

@diqiu50
Copy link
Contributor

@diqiu50 diqiu50 commented Sep 12, 2024

What changes were proposed in this pull request?

Support Iceberg partition expressions like: year(x), month(x), day(x), hour(x), bucket(x, n), truncate(x,n)
Support Iceberg sort order expressions like: field DESC, field ASC, field DESC NULLS FIRST, field ASC NULLS LAST

Why are the changes needed?

Fix: #4757

Does this PR introduce any user-facing change?

NO

How was this patch tested?

New UTs and ITs

@diqiu50 diqiu50 changed the title [#4757]feat(trino-connector): Support more partition and sort order features of Iceberg catalog [#4757]feat(trino-connector): Support more partition and sort order features of the Iceberg catalog Sep 12, 2024
@diqiu50 diqiu50 requested review from mchades and yuqi1129 and removed request for yuqi1129 September 12, 2024 11:54
@diqiu50 diqiu50 self-assigned this Sep 12, 2024
@diqiu50 diqiu50 requested a review from FANNG1 September 12, 2024 11:55
}

tasks.build {
dependsOn("setupDependencies")
Copy link
Contributor

Choose a reason for hiding this comment

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

why build dependens on setupDependencies ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Running the main class TrinoQueryTestTool requires dependencies on other modules's jars.
By default, executing the main class depends on the build task in IDEA.

shipmode varchar,
comment varchar
)
WITH (
Copy link
Contributor

Choose a reason for hiding this comment

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

how to check the partition or sort order takes effect?

Copy link
Contributor Author

@diqiu50 diqiu50 Sep 25, 2024

Choose a reason for hiding this comment

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

In the Trino , we can sue the command SHOW CREATE TABLE to check it.

if (!partitionColumns.isEmpty()) {
Transform[] partitioning =
partitionColumns.stream().map(Transforms::identity).toArray(Transform[]::new);
Transform[] partitioning = ExpressionUtil.partitionFiledToExpression(partitionColumns);
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest to use a more meaning ful name, like toGravitinoPartition

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean the function name or the parameter name.
if it's the function name . I think the name is meaningful . Actually, it transforms the partition field into an expression

return SortOrders.ascending(expression);
})
.toArray(SortOrder[]::new);
SortOrder[] sorting = ExpressionUtil.sortOrderFiledToExpression(sortColumns);
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest to use a more meaning ful name, like toGravitinoSortOrder

.map(ts -> ((Transform.SingleFieldTransform) ts).fieldName()[0])
.collect(Collectors.toList())
: Collections.emptyList());
ExpressionUtil.expressionToPartitionFiled(gravitinoTable.getPartitioning()));
Copy link
Contributor

Choose a reason for hiding this comment

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

use a more meaningful name like toTrinoPartition?

return ((NamedReference) expression).fieldName()[0];
})
.collect(Collectors.toList()));
ExpressionUtil.expressionToSortOrderFiled(gravitinoTable.getSortOrders()));
Copy link
Contributor

Choose a reason for hiding this comment

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

use a more meaningful name like toTrinoSortOrder?

}
}

private static void parseTransform(List<Transform> transforms, String value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

it's hard to maintan, is there any any better way to implement this? how origin Iceberg connector handle this logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have a better solution? the Iceberg connector handle this logic is the same as this.

@FANNG1
Copy link
Contributor

FANNG1 commented Sep 24, 2024

@yuqi1129 , do you have time to review this PR?

@diqiu50 diqiu50 requested a review from FANNG1 September 25, 2024 06:47
Copy link
Contributor

@yuqi1129 yuqi1129 left a comment

Choose a reason for hiding this comment

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

LGTM


private static void parseTransform(List<Transform> transforms, String value) {
boolean match =
false
Copy link
Contributor

Choose a reason for hiding this comment

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

magic false?

@diqiu50 diqiu50 merged commit eded019 into apache:main Oct 22, 2024
@diqiu50 diqiu50 deleted the iceberg-expr branch October 30, 2024 03:12
mplmoknijb pushed a commit to mplmoknijb/gravitino that referenced this pull request Nov 6, 2024
…rder features of the Iceberg catalog (apache#4925)

### What changes were proposed in this pull request?

Support Iceberg partition expressions like: year(x), month(x), day(x),
hour(x), bucket(x, n), truncate(x,n)
Support Iceberg sort order expressions like: field DESC, field ASC,
field DESC NULLS FIRST, field ASC NULLS LAST

### Why are the changes needed?

Fix: apache#4757

### Does this PR introduce _any_ user-facing change?

NO

### How was this patch tested?

New UTs and ITs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] trino connector support more Iceberg partitions

4 participants