@Test public void testBucketSortedTables() throws Exception { SchemaTableName table = temporaryTable("create_sorted"); try { doTestBucketSortedTables(table); } finally { dropTable(table); } }
@Test public void testInsertUnsupportedWriteType() throws Exception { SchemaTableName temporaryInsertUnsupportedWriteType = temporaryTable("insert_unsupported_type"); try { doInsertUnsupportedWriteType(ORC, temporaryInsertUnsupportedWriteType); } finally { dropTable(temporaryInsertUnsupportedWriteType); } }
@Test public void testInsertIntoNewPartition() throws Exception { for (HiveStorageFormat storageFormat : createTableFormats) { SchemaTableName temporaryInsertIntoNewPartitionTable = temporaryTable("insert_new_partitioned"); try { doInsertIntoNewPartition(storageFormat, temporaryInsertIntoNewPartitionTable); } finally { dropTable(temporaryInsertIntoNewPartitionTable); } } }
@Test public void testTableCreation() throws Exception { for (HiveStorageFormat storageFormat : createTableFormats) { SchemaTableName temporaryCreateTable = temporaryTable("create"); try { doCreateTable(temporaryCreateTable, storageFormat); } finally { dropTable(temporaryCreateTable); } } }
@Test public void testMetadataDelete() throws Exception { for (HiveStorageFormat storageFormat : createTableFormats) { SchemaTableName temporaryMetadataDeleteTable = temporaryTable("metadata_delete"); try { doTestMetadataDelete(storageFormat, temporaryMetadataDeleteTable); } finally { dropTable(temporaryMetadataDeleteTable); } } }
@Test public void testEmptyTableCreation() throws Exception { for (HiveStorageFormat storageFormat : createTableFormats) { SchemaTableName temporaryCreateEmptyTable = temporaryTable("create_empty"); try { doCreateEmptyTable(temporaryCreateEmptyTable, storageFormat, CREATE_TABLE_COLUMNS); } finally { dropTable(temporaryCreateEmptyTable); } } }
@Test public void testBucketedTableEvolution() throws Exception { for (HiveStorageFormat storageFormat : createTableFormats) { SchemaTableName temporaryBucketEvolutionTable = temporaryTable("bucket_evolution"); try { doTestBucketedTableEvolution(storageFormat, temporaryBucketEvolutionTable); } finally { dropTable(temporaryBucketEvolutionTable); } } }
@Test public void testInsert() throws Exception { for (HiveStorageFormat storageFormat : createTableFormats) { SchemaTableName temporaryInsertTable = temporaryTable("insert"); try { doInsert(storageFormat, temporaryInsertTable); } finally { dropTable(temporaryInsertTable); } } }
@Test public void testInsertIntoExistingPartition() throws Exception { for (HiveStorageFormat storageFormat : createTableFormats) { SchemaTableName temporaryInsertIntoExistingPartitionTable = temporaryTable("insert_existing_partitioned"); try { doInsertIntoExistingPartition(storageFormat, temporaryInsertIntoExistingPartitionTable); } finally { dropTable(temporaryInsertIntoExistingPartitionTable); } } }
@Test public void testInsertIntoExistingPartitionEmptyStatistics() throws Exception { for (HiveStorageFormat storageFormat : createTableFormats) { SchemaTableName temporaryInsertIntoExistingPartitionTable = temporaryTable("insert_existing_partitioned_empty_statistics"); try { doInsertIntoExistingPartitionEmptyStatistics(storageFormat, temporaryInsertIntoExistingPartitionTable); } finally { dropTable(temporaryInsertIntoExistingPartitionTable); } } }
@Test public void testUpdatePartitionColumnStatistics() throws Exception { SchemaTableName tableName = temporaryTable("update_partition_column_statistics"); try { createDummyPartitionedTable(tableName, STATISTICS_PARTITIONED_TABLE_COLUMNS); testUpdatePartitionStatistics( tableName, EMPTY_TABLE_STATISTICS, ImmutableList.of(STATISTICS_1_1, STATISTICS_1_2, STATISTICS_2), ImmutableList.of(STATISTICS_1_2, STATISTICS_1_1, STATISTICS_2)); } finally { dropTable(tableName); } }
@Test public void testUpdateBasicPartitionStatistics() throws Exception { SchemaTableName tableName = temporaryTable("update_basic_partition_statistics"); try { createDummyPartitionedTable(tableName, STATISTICS_PARTITIONED_TABLE_COLUMNS); testUpdatePartitionStatistics( tableName, EMPTY_TABLE_STATISTICS, ImmutableList.of(BASIC_STATISTICS_1, BASIC_STATISTICS_2), ImmutableList.of(BASIC_STATISTICS_2, BASIC_STATISTICS_1)); } finally { dropTable(tableName); } }
@Test public void testUpdateTableColumnStatisticsEmptyOptionalFields() throws Exception { SchemaTableName tableName = temporaryTable("update_table_column_statistics_empty_optional_fields"); try { doCreateEmptyTable(tableName, ORC, STATISTICS_TABLE_COLUMNS); testUpdateTableStatistics(tableName, EMPTY_TABLE_STATISTICS, STATISTICS_EMPTY_OPTIONAL_FIELDS); } finally { dropTable(tableName); } }
@Test public void testUpdatePartitionColumnStatisticsEmptyOptionalFields() throws Exception { SchemaTableName tableName = temporaryTable("update_partition_column_statistics"); try { createDummyPartitionedTable(tableName, STATISTICS_PARTITIONED_TABLE_COLUMNS); testUpdatePartitionStatistics( tableName, EMPTY_TABLE_STATISTICS, ImmutableList.of(STATISTICS_EMPTY_OPTIONAL_FIELDS), ImmutableList.of(STATISTICS_EMPTY_OPTIONAL_FIELDS)); } finally { dropTable(tableName); } }
@Test public void testUpdateTableColumnStatistics() throws Exception { SchemaTableName tableName = temporaryTable("update_table_column_statistics"); try { doCreateEmptyTable(tableName, ORC, STATISTICS_TABLE_COLUMNS); testUpdateTableStatistics(tableName, EMPTY_TABLE_STATISTICS, STATISTICS_1_1, STATISTICS_1_2, STATISTICS_2); } finally { dropTable(tableName); } }
@Test public void testUpdateBasicTableStatistics() throws Exception { SchemaTableName tableName = temporaryTable("update_basic_table_statistics"); try { doCreateEmptyTable(tableName, ORC, STATISTICS_TABLE_COLUMNS); testUpdateTableStatistics(tableName, EMPTY_TABLE_STATISTICS, BASIC_STATISTICS_1, BASIC_STATISTICS_2); } finally { dropTable(tableName); } }
@Test public void testMismatchSchemaTable() throws Exception { for (HiveStorageFormat storageFormat : createTableFormats) { // TODO: fix coercion for JSON if (storageFormat == JSON) { continue; } SchemaTableName temporaryMismatchSchemaTable = temporaryTable("mismatch_schema"); try { doTestMismatchSchemaTable( temporaryMismatchSchemaTable, storageFormat, MISMATCH_SCHEMA_TABLE_BEFORE, MISMATCH_SCHEMA_TABLE_DATA_BEFORE, MISMATCH_SCHEMA_TABLE_AFTER, MISMATCH_SCHEMA_TABLE_DATA_AFTER); } finally { dropTable(temporaryMismatchSchemaTable); } } }
dropTable(tableName);
@Test public void testRenameTable() { SchemaTableName temporaryRenameTableOld = temporaryTable("rename_old"); SchemaTableName temporaryRenameTableNew = temporaryTable("rename_new"); try { createDummyTable(temporaryRenameTableOld); try (Transaction transaction = newTransaction()) { ConnectorSession session = newSession(); ConnectorMetadata metadata = transaction.getMetadata(); metadata.renameTable(session, getTableHandle(metadata, temporaryRenameTableOld), temporaryRenameTableNew); transaction.commit(); } try (Transaction transaction = newTransaction()) { ConnectorSession session = newSession(); ConnectorMetadata metadata = transaction.getMetadata(); assertNull(metadata.getTableHandle(session, temporaryRenameTableOld)); assertNotNull(metadata.getTableHandle(session, temporaryRenameTableNew)); } } finally { dropTable(temporaryRenameTableOld); dropTable(temporaryRenameTableNew); } }
protected void testPartitionStatisticsSampling(List<ColumnMetadata> columns, PartitionStatistics statistics) throws Exception { SchemaTableName tableName = temporaryTable("test_partition_statistics_sampling"); try { createDummyPartitionedTable(tableName, columns); ExtendedHiveMetastore metastoreClient = getMetastoreClient(); metastoreClient.updatePartitionStatistics(tableName.getSchemaName(), tableName.getTableName(), "ds=2016-01-01", actualStatistics -> statistics); metastoreClient.updatePartitionStatistics(tableName.getSchemaName(), tableName.getTableName(), "ds=2016-01-02", actualStatistics -> statistics); try (Transaction transaction = newTransaction()) { ConnectorSession session = newSession(); ConnectorMetadata metadata = transaction.getMetadata(); ConnectorTableHandle tableHandle = metadata.getTableHandle(session, tableName); TableStatistics unsampledStatistics = metadata.getTableStatistics(sampleSize(2), tableHandle, Constraint.alwaysTrue()); TableStatistics sampledStatistics = metadata.getTableStatistics(sampleSize(1), tableHandle, Constraint.alwaysTrue()); assertEquals(sampledStatistics, unsampledStatistics); } } finally { dropTable(tableName); } }