-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add table procedures support for Lakehouse #26925
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
base: master
Are you sure you want to change the base?
Conversation
Iceberg module has several table procedure. Hive and DeltaLake modules have only the "optimize" table procedure. The code for the "optimize" table procedure is identical in all 3 modules. So, the code from Iceberg module is used. We could redeclare the table procedure in the Lakehouse module, or maybe there could be a refactoring so that the identical code for the "optimize" table procedure is placed in a common place and reused from there.
Reviewer's GuideThis PR integrates Iceberg’s table procedures into the Lakehouse connector by registering all procedure providers via a Guice Multibinder, injecting them into the connector, and exposing them through a new getTableProcedures API, along with enabling and testing the optimize procedure across Iceberg, Hive, and Delta Lake modules. Class diagram for LakehouseConnector with table procedures supportclassDiagram
class LakehouseConnector {
- LakehouseLifeCycleManager lifeCycleManager
- LakehouseTransactionManager transactionManager
- LakehouseMetadataFactory metadataFactory
- LakehouseSplitManager splitManager
- LakehouseNodePartitioningProvider nodePartitioningProvider
- LakehouseSessionProperties sessionProperties
- LakehouseTableProperties tableProperties
- IcebergMaterializedViewProperties materializedViewProperties
- Set<TableProcedureMetadata> tableProcedures
+ getTableProcedures() Set<TableProcedureMetadata>
}
class TableProcedureMetadata
LakehouseConnector --> "*" TableProcedureMetadata
Class diagram for LakehouseModule table procedure bindingsclassDiagram
class LakehouseModule {
+ setup(Binder binder)
}
class TableProcedureMetadata
class OptimizeTableProcedure
class OptimizeManifestsTableProcedure
class DropExtendedStatsTableProcedure
class RollbackToSnapshotTableProcedure
class ExpireSnapshotsTableProcedure
class RemoveOrphanFilesTableProcedure
class AddFilesTableProcedure
class AddFilesTableFromTableProcedure
LakehouseModule --> TableProcedureMetadata
TableProcedureMetadata <|-- OptimizeTableProcedure
TableProcedureMetadata <|-- OptimizeManifestsTableProcedure
TableProcedureMetadata <|-- DropExtendedStatsTableProcedure
TableProcedureMetadata <|-- RollbackToSnapshotTableProcedure
TableProcedureMetadata <|-- ExpireSnapshotsTableProcedure
TableProcedureMetadata <|-- RemoveOrphanFilesTableProcedure
TableProcedureMetadata <|-- AddFilesTableProcedure
TableProcedureMetadata <|-- AddFilesTableFromTableProcedure
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `plugin/trino-lakehouse/src/main/java/io/trino/plugin/lakehouse/LakehouseConnector.java:156-158` </location>
<code_context>
}
+ @Override
+ public Set<TableProcedureMetadata> getTableProcedures()
+ {
+ return tableProcedures;
+ }
+
</code_context>
<issue_to_address>
**suggestion:** Returning internal Set directly may expose mutability.
Return an unmodifiable view of tableProcedures to safeguard internal state from external changes.
Suggested implementation:
```java
+ @Override
+ public Set<TableProcedureMetadata> getTableProcedures()
+ {
+ return Collections.unmodifiableSet(tableProcedures);
+ }
+
```
```java
import java.util.Set;
import java.util.Collections;
```
</issue_to_address>
### Comment 2
<location> `plugin/trino-lakehouse/src/test/java/io/trino/plugin/lakehouse/TestLakehouseIcebergConnectorSmokeTest.java:49-50` </location>
<code_context>
)\\E""");
}
+
+ @Test
+ public void testOptimize()
+ {
+ String tableName = "test_optimize_" + randomNameSuffix();
</code_context>
<issue_to_address>
**suggestion (testing):** Consider adding tests for invalid procedure arguments and permissions.
Please add tests for invalid argument types, missing required arguments, and permission failures to improve error handling and security coverage.
</issue_to_address>
### Comment 3
<location> `plugin/trino-lakehouse/src/test/java/io/trino/plugin/lakehouse/TestLakehouseHiveConnectorSmokeTest.java:72-73` </location>
<code_context>
)\\E""");
}
+
+ @Test
+ public void testOptimize()
+ {
+ String tableName = "test_optimize_" + randomNameSuffix();
</code_context>
<issue_to_address>
**suggestion (testing):** Add test for optimize procedure with invalid session property value.
Please add a test case for an invalid session property value to verify the connector's handling of unexpected input.
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
public Set<TableProcedureMetadata> getTableProcedures() | ||
{ | ||
return tableProcedures; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Returning internal Set directly may expose mutability.
Return an unmodifiable view of tableProcedures to safeguard internal state from external changes.
Suggested implementation:
+ @Override
+ public Set<TableProcedureMetadata> getTableProcedures()
+ {
+ return Collections.unmodifiableSet(tableProcedures);
+ }
+
import java.util.Set;
import java.util.Collections;
@Test | ||
public void testOptimize() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (testing): Add test for optimize procedure with invalid session property value.
Please add a test case for an invalid session property value to verify the connector's handling of unexpected input.
Add table procedures support for Lakehouse
Fixes #26754
Description
Iceberg module has several table procedures.
Hive and DeltaLake modules have only the "optimize" table procedure.
The code for the "optimize" table procedure is identical in all 3 modules.
So, the code from Iceberg module is used.
We could redeclare the table procedure in the Lakehouse module, or maybe there could be a refactoring so that the identical code for the "optimize" table procedure is placed in a common place and reused from there.
Additional context and related issues
Release notes
( ) This is not user-visible or is docs only, and no release notes are required.
(X) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:
Summary by Sourcery
Introduce support for Iceberg-style table procedures in the Lakehouse connector by registering and exposing procedure metadata, and add smoke tests validating these procedures in Iceberg, Hive, and Delta modules.
New Features:
Enhancements:
Tests: