use of io.prestosql.sql.planner.planprinter.IoPlanPrinter.IoPlan in project hetu-core by openlookeng.
the class TestHiveIntegrationSmokeTest method testIoExplainWithPrimitiveTypes.
@Test
public void testIoExplainWithPrimitiveTypes() {
Map<Object, Type> data = new HashMap<>();
data.put("foo", VarcharType.createUnboundedVarcharType());
data.put(Byte.toString((byte) (Byte.MAX_VALUE / 2)), TinyintType.TINYINT);
data.put(Short.toString((short) (Short.MAX_VALUE / 2)), SmallintType.SMALLINT);
data.put(Integer.toString(Integer.MAX_VALUE / 2), IntegerType.INTEGER);
data.put(Long.toString(Long.MAX_VALUE / 2), BigintType.BIGINT);
data.put(Boolean.TRUE.toString(), BooleanType.BOOLEAN);
data.put("bar", CharType.createCharType(3));
data.put("1.2345678901234578E14", DoubleType.DOUBLE);
data.put("123456789012345678901234.567", DecimalType.createDecimalType(30, 3));
data.put("2019-01-01", DateType.DATE);
data.put("2019-01-01 23:22:21.123", TimestampType.TIMESTAMP);
for (Map.Entry<Object, Type> entry : data.entrySet()) {
@Language("SQL") String query = format("CREATE TABLE test_types_table WITH (partitioned_by = ARRAY['my_col']) AS " + "SELECT 'foo' my_non_partition_col, CAST('%s' AS %s) my_col", entry.getKey(), entry.getValue().getDisplayName());
assertUpdate(query, 1);
MaterializedResult result = computeActual("EXPLAIN (TYPE IO, FORMAT JSON) SELECT * FROM test_types_table");
assertEquals(jsonCodec(IoPlan.class).fromJson((String) getOnlyElement(result.getOnlyColumnAsSet())), new IoPlan(ImmutableSet.of(new TableColumnInfo(new CatalogSchemaTableName(catalog, "tpch", "test_types_table"), ImmutableSet.of(new ColumnConstraint("my_col", entry.getValue().getTypeSignature(), new FormattedDomain(false, ImmutableSet.of(new FormattedRange(new FormattedMarker(Optional.of(entry.getKey().toString()), EXACTLY), new FormattedMarker(Optional.of(entry.getKey().toString()), EXACTLY)))))))), Optional.empty()));
assertUpdate("DROP TABLE test_types_table");
}
}
use of io.prestosql.sql.planner.planprinter.IoPlanPrinter.IoPlan in project hetu-core by openlookeng.
the class TestHiveIntegrationSmokeTest method testIOExplain.
@Test
public void testIOExplain() {
// Test IO explain with small number of discrete components.
computeActual("CREATE TABLE test_orders WITH (partitioned_by = ARRAY['orderkey', 'processing']) AS select custkey, orderkey, orderstatus = 'P' processing FROM orders where orderkey < 3");
MaterializedResult result = computeActual("EXPLAIN (TYPE IO, FORMAT JSON) INSERT INTO test_orders SELECT custkey, orderkey, processing FROM test_orders where custkey <= 10");
assertEquals(jsonCodec(IoPlan.class).fromJson((String) getOnlyElement(result.getOnlyColumnAsSet())), new IoPlan(ImmutableSet.of(new TableColumnInfo(new CatalogSchemaTableName(catalog, "tpch", "test_orders"), ImmutableSet.of(new ColumnConstraint("orderkey", BIGINT.getTypeSignature(), new FormattedDomain(false, ImmutableSet.of(new FormattedRange(new FormattedMarker(Optional.of("1"), EXACTLY), new FormattedMarker(Optional.of("1"), EXACTLY)), new FormattedRange(new FormattedMarker(Optional.of("2"), EXACTLY), new FormattedMarker(Optional.of("2"), EXACTLY))))), new ColumnConstraint("processing", BOOLEAN.getTypeSignature(), new FormattedDomain(false, ImmutableSet.of(new FormattedRange(new FormattedMarker(Optional.of("false"), EXACTLY), new FormattedMarker(Optional.of("false"), EXACTLY)))))))), Optional.of(new CatalogSchemaTableName(catalog, "tpch", "test_orders"))));
assertUpdate("DROP TABLE test_orders");
// Test IO explain with large number of discrete components where Domain::simpify comes into play.
computeActual("CREATE TABLE test_orders WITH (partitioned_by = ARRAY['orderkey']) AS select custkey, orderkey FROM orders where orderkey < 200");
result = computeActual("EXPLAIN (TYPE IO, FORMAT JSON) INSERT INTO test_orders SELECT custkey, orderkey + 10 FROM test_orders where custkey <= 10");
assertEquals(jsonCodec(IoPlan.class).fromJson((String) getOnlyElement(result.getOnlyColumnAsSet())), new IoPlan(ImmutableSet.of(new TableColumnInfo(new CatalogSchemaTableName(catalog, "tpch", "test_orders"), ImmutableSet.of(new ColumnConstraint("orderkey", BIGINT.getTypeSignature(), new FormattedDomain(false, ImmutableSet.of(new FormattedRange(new FormattedMarker(Optional.of("1"), EXACTLY), new FormattedMarker(Optional.of("199"), EXACTLY)))))))), Optional.of(new CatalogSchemaTableName(catalog, "tpch", "test_orders"))));
assertUpdate("DROP TABLE test_orders");
}
Aggregations