use of io.trino.tests.product.hive.util.TemporaryHiveTable in project trino by trinodb.
the class TestHivePartitionSchemaEvolution method createTable.
private TemporaryHiveTable createTable(String format) {
String tableName = "schema_evolution_" + randomTableSuffix();
tryExecuteOnHive(format("CREATE TABLE %s (" + " int_column int," + " float_column float," + " varchar_column varchar(20)" + ") " + "PARTITIONED BY (partition_column bigint) " + "STORED AS %s " + (createTablesAsAcid ? "TBLPROPERTIES ('transactional_properties' = 'none', 'transactional' = 'false')" : ""), tableName, format));
TemporaryHiveTable temporaryHiveTable = temporaryHiveTable(tableName);
try {
onTrino().executeQuery(format("INSERT INTO %s VALUES (1, 1.1, 'jeden', 1)", tableName));
} catch (Exception e) {
temporaryHiveTable.closeQuietly(e);
throw e;
}
return temporaryHiveTable;
}
use of io.trino.tests.product.hive.util.TemporaryHiveTable in project trino by trinodb.
the class TestHivePartitionSchemaEvolution method test.
private void test(Supplier<TemporaryHiveTable> temporaryHiveTableSupplier) {
try (TemporaryHiveTable table = temporaryHiveTableSupplier.get()) {
// dropping column on table, simulates creating a column on partition
// adding column on table, simulates dropping a column on partition
// partition is adding a column at the start
testEvolution(table, "ALTER TABLE %s REPLACE COLUMNS (float_column float, varchar_column varchar(20))", row(1.1, "jeden", 1));
// partition is adding a column in the middle
testEvolution(table, "ALTER TABLE %s REPLACE COLUMNS (int_column int, varchar_column varchar(20))", row(1, "jeden", 1));
// partition is adding a column at the end
testEvolution(table, "ALTER TABLE %s REPLACE COLUMNS (int_column int, float_column float)", row(1, 1.1, 1));
// partition is dropping a column at the start
testEvolution(table, "ALTER TABLE %s REPLACE COLUMNS (tiny_column tinyint, int_column int, float_column float, varchar_column varchar(20))", row(null, 1, 1.1, "jeden", 1));
// partition is dropping a column in the middle
testEvolution(table, "ALTER TABLE %s REPLACE COLUMNS (int_column int, tiny_column tinyint, float_column float, varchar_column varchar(20))", row(1, null, 1.1, "jeden", 1));
// partition is dropping a column at the end
testEvolution(table, "ALTER TABLE %s REPLACE COLUMNS (int_column int, float_column float, varchar_column varchar(20), tiny_column tinyint)", row(1, 1.1, "jeden", null, 1));
// partition is dropping and adding column in the middle
testEvolution(table, "ALTER TABLE %s REPLACE COLUMNS (int_column int, tiny_column tinyint, varchar_column varchar(20))", row(1, null, "jeden", 1));
// partition is adding coercions
testEvolution(table, "ALTER TABLE %s REPLACE COLUMNS (int_column bigint, float_column double, varchar_column varchar(20))", row(1, 1.1, "jeden", 1));
// partition is swapping columns with coercions
testEvolution(table, "ALTER TABLE %s REPLACE COLUMNS (varchar_column varchar(20), float_column double, int_column bigint)", row("jeden", 1.1, 1, 1));
// partition is swapping columns and partition with coercions and is adding a column
testEvolution(table, "ALTER TABLE %s REPLACE COLUMNS (float_column double, int_column bigint)", row(1.1, 1, 1));
// partition is swapping columns and partition with coercions and is removing a column
testEvolution(table, "ALTER TABLE %s REPLACE COLUMNS (varchar_column varchar(20), tiny_column tinyint, float_column double, int_column bigint)", row("jeden", null, 1.1, 1, 1));
}
}
Aggregations