use of io.prestosql.spi.type.DecimalType.createDecimalType 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");
}
}
Aggregations