use of io.trino.spi.connector.SchemaTableName in project trino by trinodb.
the class AbstractTestHive method testUpdatePartitionColumnStatisticsEmptyOptionalFields.
@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);
}
}
use of io.trino.spi.connector.SchemaTableName in project trino by trinodb.
the class AbstractTestHive method testMaterializedViewMetadata.
@Test
public void testMaterializedViewMetadata() throws Exception {
SchemaTableName sourceTableName = temporaryTable("materialized_view_tester");
doCreateEmptyTable(sourceTableName, ORC, CREATE_TABLE_COLUMNS);
SchemaTableName tableName = temporaryTable("mock_table");
doCreateEmptyTable(tableName, ORC, CREATE_TABLE_COLUMNS);
try (Transaction transaction = newTransaction()) {
ConnectorSession session = newSession();
ConnectorMetadata metadata = transaction.getMetadata();
assertThat(metadata.getMaterializedView(session, tableName)).isEmpty();
Optional<ConnectorMaterializedViewDefinition> result = metadata.getMaterializedView(session, sourceTableName);
assertThat(result).isPresent();
assertThat(result.get().getOriginalSql()).isEqualTo("dummy_view_sql");
} finally {
dropTable(sourceTableName);
dropTable(tableName);
}
}
use of io.trino.spi.connector.SchemaTableName in project trino by trinodb.
the class AbstractTestHive method assertEmptyFile.
private void assertEmptyFile(HiveStorageFormat format) throws Exception {
SchemaTableName tableName = temporaryTable("empty_file");
try {
List<Column> columns = ImmutableList.of(new Column("test", HIVE_STRING, Optional.empty()));
createEmptyTable(tableName, format, columns, ImmutableList.of());
try (Transaction transaction = newTransaction()) {
ConnectorSession session = newSession();
ConnectorMetadata metadata = transaction.getMetadata();
metadata.beginQuery(session);
ConnectorTableHandle tableHandle = getTableHandle(metadata, tableName);
List<ColumnHandle> columnHandles = filterNonHiddenColumnHandles(metadata.getColumnHandles(session, tableHandle).values());
Table table = transaction.getMetastore().getTable(tableName.getSchemaName(), tableName.getTableName()).orElseThrow(AssertionError::new);
// verify directory is empty
HdfsContext context = new HdfsContext(session);
Path location = new Path(table.getStorage().getLocation());
assertTrue(listDirectory(context, location).isEmpty());
// read table with empty directory
readTable(transaction, tableHandle, columnHandles, session, TupleDomain.all(), OptionalInt.of(0), Optional.of(ORC));
// create empty file
FileSystem fileSystem = hdfsEnvironment.getFileSystem(context, location);
assertTrue(fileSystem.createNewFile(new Path(location, "empty-file")));
assertEquals(listDirectory(context, location), ImmutableList.of("empty-file"));
// read table with empty file
MaterializedResult result = readTable(transaction, tableHandle, columnHandles, session, TupleDomain.all(), OptionalInt.of(0), Optional.empty());
assertEquals(result.getRowCount(), 0);
}
} finally {
dropTable(tableName);
}
}
use of io.trino.spi.connector.SchemaTableName in project trino by trinodb.
the class AbstractTestHive method testUpdateTableColumnStatistics.
@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);
}
}
use of io.trino.spi.connector.SchemaTableName in project trino by trinodb.
the class AbstractTestHive method testApplyRedirection.
@Test
public void testApplyRedirection() throws Exception {
SchemaTableName sourceTableName = temporaryTable("apply_redirection_tester");
doCreateEmptyTable(sourceTableName, ORC, CREATE_TABLE_COLUMNS);
SchemaTableName tableName = temporaryTable("apply_no_redirection_tester");
doCreateEmptyTable(tableName, ORC, CREATE_TABLE_COLUMNS);
try (Transaction transaction = newTransaction()) {
ConnectorSession session = newSession();
ConnectorMetadata metadata = transaction.getMetadata();
assertThat(metadata.applyTableScanRedirect(session, getTableHandle(metadata, tableName))).isEmpty();
Optional<TableScanRedirectApplicationResult> result = metadata.applyTableScanRedirect(session, getTableHandle(metadata, sourceTableName));
assertThat(result).isPresent();
assertThat(result.get().getDestinationTable()).isEqualTo(new CatalogSchemaTableName("hive", database, "mock_redirection_target"));
} finally {
dropTable(sourceTableName);
dropTable(tableName);
}
}
Aggregations