Search in sources :

Example 1 with TableColumnInfo

use of io.prestosql.sql.planner.planprinter.IoPlanPrinter.IoPlan.TableColumnInfo 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");
    }
}
Also used : HashMap(java.util.HashMap) CatalogSchemaTableName(io.prestosql.spi.connector.CatalogSchemaTableName) JoinDistributionType(io.prestosql.sql.analyzer.FeaturesConfig.JoinDistributionType) VarcharType.createVarcharType(io.prestosql.spi.type.VarcharType.createVarcharType) TimestampType(io.prestosql.spi.type.TimestampType) CharType(io.prestosql.spi.type.CharType) IntegerType(io.prestosql.spi.type.IntegerType) TinyintType(io.prestosql.spi.type.TinyintType) BooleanType(io.prestosql.spi.type.BooleanType) VarcharType(io.prestosql.spi.type.VarcharType) DecimalType(io.prestosql.spi.type.DecimalType) Type(io.prestosql.spi.type.Type) DecimalType.createDecimalType(io.prestosql.spi.type.DecimalType.createDecimalType) CharType.createCharType(io.prestosql.spi.type.CharType.createCharType) VarcharType.createUnboundedVarcharType(io.prestosql.spi.type.VarcharType.createUnboundedVarcharType) BigintType(io.prestosql.spi.type.BigintType) DoubleType(io.prestosql.spi.type.DoubleType) SmallintType(io.prestosql.spi.type.SmallintType) DateType(io.prestosql.spi.type.DateType) Language(org.intellij.lang.annotations.Language) FormattedDomain(io.prestosql.sql.planner.planprinter.IoPlanPrinter.FormattedDomain) ColumnConstraint(io.prestosql.sql.planner.planprinter.IoPlanPrinter.ColumnConstraint) TableColumnInfo(io.prestosql.sql.planner.planprinter.IoPlanPrinter.IoPlan.TableColumnInfo) FormattedMarker(io.prestosql.sql.planner.planprinter.IoPlanPrinter.FormattedMarker) FormattedRange(io.prestosql.sql.planner.planprinter.IoPlanPrinter.FormattedRange) MaterializedResult(io.prestosql.testing.MaterializedResult) IoPlan(io.prestosql.sql.planner.planprinter.IoPlanPrinter.IoPlan) Map(java.util.Map) NodeTaskMap(io.prestosql.execution.NodeTaskMap) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) Test(org.testng.annotations.Test) AbstractTestIntegrationSmokeTest(io.prestosql.tests.AbstractTestIntegrationSmokeTest)

Example 2 with TableColumnInfo

use of io.prestosql.sql.planner.planprinter.IoPlanPrinter.IoPlan.TableColumnInfo 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");
}
Also used : FormattedDomain(io.prestosql.sql.planner.planprinter.IoPlanPrinter.FormattedDomain) ColumnConstraint(io.prestosql.sql.planner.planprinter.IoPlanPrinter.ColumnConstraint) TableColumnInfo(io.prestosql.sql.planner.planprinter.IoPlanPrinter.IoPlan.TableColumnInfo) FormattedMarker(io.prestosql.sql.planner.planprinter.IoPlanPrinter.FormattedMarker) FormattedRange(io.prestosql.sql.planner.planprinter.IoPlanPrinter.FormattedRange) MaterializedResult(io.prestosql.testing.MaterializedResult) IoPlan(io.prestosql.sql.planner.planprinter.IoPlanPrinter.IoPlan) CatalogSchemaTableName(io.prestosql.spi.connector.CatalogSchemaTableName) Test(org.testng.annotations.Test) AbstractTestIntegrationSmokeTest(io.prestosql.tests.AbstractTestIntegrationSmokeTest)

Aggregations

CatalogSchemaTableName (io.prestosql.spi.connector.CatalogSchemaTableName)2 ColumnConstraint (io.prestosql.sql.planner.planprinter.IoPlanPrinter.ColumnConstraint)2 FormattedDomain (io.prestosql.sql.planner.planprinter.IoPlanPrinter.FormattedDomain)2 FormattedMarker (io.prestosql.sql.planner.planprinter.IoPlanPrinter.FormattedMarker)2 FormattedRange (io.prestosql.sql.planner.planprinter.IoPlanPrinter.FormattedRange)2 IoPlan (io.prestosql.sql.planner.planprinter.IoPlanPrinter.IoPlan)2 TableColumnInfo (io.prestosql.sql.planner.planprinter.IoPlanPrinter.IoPlan.TableColumnInfo)2 MaterializedResult (io.prestosql.testing.MaterializedResult)2 AbstractTestIntegrationSmokeTest (io.prestosql.tests.AbstractTestIntegrationSmokeTest)2 Test (org.testng.annotations.Test)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 NodeTaskMap (io.prestosql.execution.NodeTaskMap)1 BigintType (io.prestosql.spi.type.BigintType)1 BooleanType (io.prestosql.spi.type.BooleanType)1 CharType (io.prestosql.spi.type.CharType)1 CharType.createCharType (io.prestosql.spi.type.CharType.createCharType)1 DateType (io.prestosql.spi.type.DateType)1 DecimalType (io.prestosql.spi.type.DecimalType)1 DecimalType.createDecimalType (io.prestosql.spi.type.DecimalType.createDecimalType)1 DoubleType (io.prestosql.spi.type.DoubleType)1