-
Couldn't load subscription status.
- 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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,11 +13,13 @@ | |
| */ | ||
| package io.trino.plugin.lakehouse; | ||
|
|
||
| import io.trino.Session; | ||
| import io.trino.testing.TestingConnectorBehavior; | ||
| import io.trino.testing.sql.TestTable; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static io.trino.plugin.lakehouse.TableType.HIVE; | ||
| import static io.trino.testing.TestingNames.randomNameSuffix; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| public class TestLakehouseHiveConnectorSmokeTest | ||
|
|
@@ -66,4 +68,28 @@ comment varchar(152) | |
| type = 'HIVE' | ||
| )"""); | ||
| } | ||
|
|
||
| @Test | ||
| public void testOptimize() | ||
|
Comment on lines
+72
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| { | ||
| String tableName = "test_optimize_" + randomNameSuffix(); | ||
| assertUpdate("CREATE TABLE " + tableName + " (key integer, value varchar)"); | ||
| try { | ||
| assertThat(query("ALTER TABLE " + tableName + " EXECUTE optimize(file_size_threshold => '10kB')")) | ||
| .failure().hasMessage("OPTIMIZE procedure must be explicitly enabled via non_transactional_optimize_enabled session property"); | ||
|
|
||
| Session session = optimizeEnabledSession(); | ||
| assertThat(query(session, "ALTER TABLE " + tableName + " EXECUTE optimize(file_size_threshold => '10kB')")).succeeds(); | ||
| } | ||
| finally { | ||
| assertUpdate("DROP TABLE " + tableName); | ||
| } | ||
| } | ||
|
|
||
| private Session optimizeEnabledSession() | ||
| { | ||
| return Session.builder(getSession()) | ||
| .setCatalogSessionProperty(getSession().getCatalog().orElseThrow(), "non_transactional_optimize_enabled", "true") | ||
| .build(); | ||
| } | ||
| } | ||
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: