-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Do not create temp staging directory for CREATE TABLE without data #5802
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
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 |
|---|---|---|
|
|
@@ -247,6 +247,7 @@ | |
| import static io.prestosql.plugin.hive.util.HiveUtil.toPartitionValues; | ||
| import static io.prestosql.plugin.hive.util.HiveWriteUtils.createDirectory; | ||
| import static io.prestosql.plugin.hive.util.HiveWriteUtils.getTableDefaultLocation; | ||
| import static io.prestosql.plugin.hive.util.HiveWriteUtils.pathExists; | ||
| import static io.prestosql.spi.StandardErrorCode.NOT_SUPPORTED; | ||
| import static io.prestosql.spi.StandardErrorCode.TRANSACTION_CONFLICT; | ||
| import static io.prestosql.spi.connector.ConnectorSplitManager.SplitSchedulingStrategy.UNGROUPED_SCHEDULING; | ||
|
|
@@ -2207,7 +2208,7 @@ public void testTableCreationIgnoreExisting() | |
| try { | ||
| try (Transaction transaction = newTransaction()) { | ||
| LocationService locationService = getLocationService(); | ||
| LocationHandle locationHandle = locationService.forNewTable(transaction.getMetastore(), session, schemaName, tableName, Optional.empty()); | ||
| LocationHandle locationHandle = locationService.forNewTable(transaction.getMetastore(), session, schemaName, tableName, Optional.empty(), false); | ||
| targetPath = locationService.getQueryWriteInfo(locationHandle).getTargetPath(); | ||
| Table table = createSimpleTable(schemaTableName, columns, session, targetPath, "q1"); | ||
| transaction.getMetastore() | ||
|
|
@@ -2539,6 +2540,59 @@ public void testEmptyTableCreation() | |
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testCreateEmptyTableStaging() | ||
| { | ||
| for (HiveStorageFormat storageFormat : createTableFormats) { | ||
| SchemaTableName temporaryCreateEmptyTable = temporaryTable("create_empty_staging"); | ||
| try { | ||
| List<Column> columns = ImmutableList.of(new Column("test", HIVE_STRING, Optional.empty())); | ||
| try (Transaction transaction = newTransaction()) { | ||
| ConnectorSession session = newSession(); | ||
| String tableOwner = session.getUser(); | ||
| String schemaName = temporaryCreateEmptyTable.getSchemaName(); | ||
| String tableName = temporaryCreateEmptyTable.getTableName(); | ||
| LocationService locationService = getLocationService(); | ||
| LocationHandle locationHandle = locationService.forNewTable(transaction.getMetastore(), | ||
|
Member
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. each arg in newline |
||
| session, | ||
| schemaName, | ||
| tableName, | ||
| Optional.empty(), | ||
| false); | ||
| Path writePath = locationService.getQueryWriteInfo(locationHandle).getWritePath(); | ||
| Path targetPath = locationService.getQueryWriteInfo(locationHandle).getTargetPath(); | ||
| Table.Builder tableBuilder = Table.builder() | ||
| .setDatabaseName(schemaName) | ||
| .setTableName(tableName) | ||
| .setOwner(tableOwner) | ||
| .setTableType(TableType.MANAGED_TABLE.name()) | ||
| .setParameters(ImmutableMap.of( | ||
| PRESTO_VERSION_NAME, TEST_SERVER_VERSION, | ||
| PRESTO_QUERY_ID_NAME, session.getQueryId())) | ||
| .setDataColumns(columns) | ||
| .setPartitionColumns(ImmutableList.of()); | ||
| tableBuilder.getStorageBuilder() | ||
| .setLocation(targetPath.toString()) | ||
| .setStorageFormat(StorageFormat.create(storageFormat.getSerDe(), storageFormat.getInputFormat(), storageFormat.getOutputFormat())) | ||
| .setBucketProperty(Optional.empty()) | ||
| .setSerdeParameters(ImmutableMap.of()); | ||
| PrincipalPrivileges principalPrivileges = testingPrincipalPrivilege(tableOwner, session.getUser()); | ||
| transaction.getMetastore().createTable(session, tableBuilder.build(), principalPrivileges, Optional.empty(), true, EMPTY_TABLE_STATISTICS); | ||
| transaction.commit(); | ||
|
|
||
| HdfsContext context = new HdfsContext(session, schemaName, tableName); | ||
| if (locationHandle.getWriteMode() == STAGE_AND_MOVE_TO_TARGET_DIRECTORY) { | ||
| assertFalse(pathExists(context, hdfsEnvironment, writePath), | ||
|
Member
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.
What you should do instead is to set some random staging directory (via |
||
| "temp staging directory " + writePath.toString() + " exists"); | ||
| } | ||
| } | ||
| } | ||
| finally { | ||
| dropTable(temporaryCreateEmptyTable); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testViewCreation() | ||
| { | ||
|
|
@@ -2783,7 +2837,7 @@ public void testIllegalStorageFormatDuringTableScan() | |
| String tableOwner = session.getUser(); | ||
| String schemaName = schemaTableName.getSchemaName(); | ||
| String tableName = schemaTableName.getTableName(); | ||
| LocationHandle locationHandle = locationService.forNewTable(transaction.getMetastore(), session, schemaName, tableName, Optional.empty()); | ||
| LocationHandle locationHandle = locationService.forNewTable(transaction.getMetastore(), session, schemaName, tableName, Optional.empty(), false); | ||
| Path targetPath = locationService.getQueryWriteInfo(locationHandle).getTargetPath(); | ||
| //create table whose storage format is null | ||
| Table.Builder tableBuilder = Table.builder() | ||
|
|
@@ -4730,7 +4784,7 @@ private void createEmptyTable(SchemaTableName schemaTableName, HiveStorageFormat | |
| String tableName = schemaTableName.getTableName(); | ||
|
|
||
| LocationService locationService = getLocationService(); | ||
| LocationHandle locationHandle = locationService.forNewTable(transaction.getMetastore(), session, schemaName, tableName, Optional.empty()); | ||
| LocationHandle locationHandle = locationService.forNewTable(transaction.getMetastore(), session, schemaName, tableName, Optional.empty(), false); | ||
| targetPath = locationService.getQueryWriteInfo(locationHandle).getTargetPath(); | ||
|
|
||
| Table.Builder tableBuilder = Table.builder() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.