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

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

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 yuqi1129 and mchades 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.

@@ -126,20 +120,12 @@ public GravitinoTable createTable(ConnectorTableMetadata tableMetadata) {
new GravitinoTable(schemaName, tableName, columns, comment, properties);

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
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
2 participants