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
Preserve table catalog/schema in ALTER TABLE qualified_name RENAME TO unqualified_name #11282
Conversation
a599643
to
933601c
Compare
The CI is red. |
ff4914f
to
103c870
Compare
@Override | ||
public void testRenameTableUnqualifiedName() | ||
{ | ||
// override needed to provide valid location for schema (it needs to be s3:// based). By default schema is assigned hdfs:// location |
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.
Can we have a method in BCT to fill in required table properties (default: none), so that we don't need to override such nice and verbose test method?
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.
Thank you for seeing this cleaner way to customize the tests for delta lake.
By using a createSchema(String schemaName)
method, we can spare the duplication of the test methods.
{ | ||
// override needed to provide valid location for schema (it needs to be s3:// based). By default schema is assigned hdfs:// location | ||
// TODO: better fix would be to configure hadoop container we use in test to use `s3://` filesystem by default | ||
skipTestUnless(hasBehavior(SUPPORTS_CREATE_SCHEMA) && hasBehavior(SUPPORTS_CREATE_TABLE)); |
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.
add empty line after // TODO: better fix would
, since the code line and comment are unrelated
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.
BTW skipTestUnless
is not needed in a specific test class (here), because it knows what it does and doesn't support
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.
Not applying anymore because the duplicated test method has been removed from the class.
@@ -1674,6 +1674,36 @@ public void testRenameTableAcrossSchema() | |||
assertFalse(getQueryRunner().tableExists(getSession(), renamedTable)); | |||
} | |||
|
|||
@Test | |||
public void testRenameTableUnqualifiedName() |
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.
in prep commit move testRenameTableAcrossSchema
directly below testRenameTable
and then add this new test after the two
testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java
Outdated
Show resolved
Hide resolved
testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java
Outdated
Show resolved
Hide resolved
testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java
Outdated
Show resolved
Hide resolved
testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java
Outdated
Show resolved
Hide resolved
103c870
to
b28412f
Compare
|
||
String renamedTable = "test_rename_unqualified_name_new_" + randomTableSuffix(); | ||
assertUpdate("ALTER TABLE " + sourceSchemaName + "." + tableName + " RENAME TO " + renamedTable); | ||
assertFalse(getQueryRunner().tableExists(getSession(), tableName)); |
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.
actually, assertFalse(getQueryRunner().tableExists(getSession(), tableName));
would succeed even before rename. You don't pass sourceSchemaName
here (and you cannot).
For simplicity, let's skip the assertion.
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.
(applied)
When dealing with unqualified object names for the target table, use the source table name for deducing the target qualified object name.
b28412f
to
cbbd514
Compare
Description
When performing
ALTER TABLE xxx RENAME TO yyy
deduce the qualified object name ofyyy
from the session and use the source as a fallbackThis is a bugfix.
Fix.
See #11281
Related issues, pull requests, and links
Fixes #11281
Documentation
(x) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
(x) No release notes entries required.
( ) Release notes entries required with the following suggested text: