-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Do not create temporary staging path for CREATE TABLE statement #14830
Conversation
cc: @phd3 |
50a62c3
to
149d23e
Compare
8c9edbb
to
4c09730
Compare
@@ -27,6 +27,8 @@ | |||
{ | |||
LocationHandle forNewTable(SemiTransactionalHiveMetastore metastore, ConnectorSession session, String schemaName, String tableName, Optional<Path> externalLocation); |
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.
l'd simplify this as below - as we don't care about external location anyway.
Path forNewTable(SemiTransactionalHiveMetastore metastore, ConnectorSession session, String schemaName, String tableName);
.setBucketProperty(Optional.empty()) | ||
.setSerdeParameters(ImmutableMap.of()); |
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.
nit: if nothing specific being set - better to remove as this is default ?
PRESTO_VERSION_NAME, TEST_SERVER_VERSION, | ||
PRESTO_QUERY_ID_NAME, session.getQueryId())) | ||
.setDataColumns(columns) | ||
.setPartitionColumns(ImmutableList.of()); |
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.
remove?
.setStorageFormat(StorageFormat.create(storageFormat.getSerde(), storageFormat.getInputFormat(), storageFormat.getOutputFormat())) | ||
.setBucketProperty(Optional.empty()) | ||
.setSerdeParameters(ImmutableMap.of()); | ||
PrincipalPrivileges principalPrivileges = testingPrincipalPrivilege(tableOwner, session.getUser()); |
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.
nit: inline
.setBucketProperty(Optional.empty()) | ||
.setSerdeParameters(ImmutableMap.of()); | ||
PrincipalPrivileges principalPrivileges = testingPrincipalPrivilege(tableOwner, session.getUser()); | ||
transaction.getMetastore().createTable(session, tableBuilder.build(), principalPrivileges, Optional.empty(), Optional.empty(), true, EMPTY_TABLE_STATISTICS, false); |
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.
nit: split args once above is inlined
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.
@phd3 I'll address these comments in next revision.
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.
@phd3 I have made changes according to your comments above. Please take a look when you have time. Thanks!
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.
IIUC this comment is suggesting to change split the arguments of the method call on line 3011
to separate lines with principalPrivileges
inlined.
967e690
to
dc98ad6
Compare
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.
lgtm, just one comment
@@ -341,6 +341,8 @@ | |||
|
|||
protected static final String TEST_SERVER_VERSION = "test_version"; | |||
|
|||
protected static final String FIXED_TEMPORARY_STAGING_PREFIX = "fixed-hive-staging-prefix"; |
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.
I'd actually use a test-local prefix (with a random suffix) - as any reuse of this static variable in future tests can potentially break 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.
Makes sense; I'll make the change.
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.
@phd3 I've addressed this change in the new commit. Please take a look when you have time. Thanks!
dc98ad6
to
3e85252
Compare
3e85252
to
792310e
Compare
Description
I am continuing the work in #5802 .
The issue is that both
CREATE TABLE
andCREATE TABLE AS ...
useforNewTable
to generate aLocationHandle
. In subsequent operations the directory created forCREATE TABLE
is never renamed as the target directory because there was no data written to it.The solution is to not create any temporary staging directory for
CREATE TABLE
operations. As suggested by the previous discussion I decided to create a new APIforNewTableAsSelect
inLocationService
, and modify the originalforNewTable
to not create any temporary staging directory as it should.Non-technical explanation
Currently during
CREATE TABLE
operation, Trino creates a unnecessary directory that is not used and cleaned up afterwards. This patch will fix this issue.(x) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text: