use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class PhoenixDataTypeTest method testArrayType.
@Test
public void testArrayType() throws Exception {
String sql = "select * from phoenix123.v1.arraytype";
QueryBuilder builder = queryBuilder().sql(sql);
RowSet sets = builder.rowSet();
TupleMetadata schema = new SchemaBuilder().addNullable("T_UUID", MinorType.VARCHAR).addArray("T_VARCHAR", MinorType.VARCHAR).addArray("T_CHAR", MinorType.VARCHAR).addArray("T_BIGINT", MinorType.BIGINT).addArray("T_INTEGER", MinorType.INT).addArray("T_DOUBLE", MinorType.FLOAT8).addArray("T_SMALLINT", MinorType.SMALLINT).addArray("T_TINYINT", MinorType.TINYINT).addArray("T_BOOLEAN", MinorType.BIT).build();
RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow(U_U_I_D, strArray("apache", "drill", "1.20"), strArray("a", "b", "c"), longArray(Long.MIN_VALUE, Long.MAX_VALUE), intArray(Integer.MIN_VALUE, Integer.MAX_VALUE), doubleArray(Double.MIN_VALUE, Double.MAX_VALUE), shortArray(Short.MIN_VALUE, Short.MAX_VALUE), byteArray((int) Byte.MIN_VALUE, (int) Byte.MAX_VALUE), boolArray(Boolean.TRUE, Boolean.FALSE)).build();
new RowSetComparison(expected).verifyAndClearAll(sets);
}
use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class SecuredPhoenixDataTypeTest method doTestDataType.
private void doTestDataType() throws Exception {
String sql = "select * from phoenix123.v1.datatype";
QueryBuilder builder = queryBuilder().sql(sql);
RowSet sets = builder.rowSet();
TupleMetadata schema = new SchemaBuilder().addNullable("T_UUID", MinorType.VARCHAR).addNullable("T_VARCHAR", MinorType.VARCHAR).addNullable("T_CHAR", MinorType.VARCHAR).addNullable("T_BIGINT", MinorType.BIGINT).addNullable("T_INTEGER", MinorType.INT).addNullable("T_SMALLINT", MinorType.INT).addNullable("T_TINYINT", MinorType.INT).addNullable("T_DOUBLE", MinorType.FLOAT8).addNullable("T_FLOAT", MinorType.FLOAT4).addNullable("T_DECIMAL", MinorType.VARDECIMAL).addNullable("T_DATE", MinorType.DATE).addNullable("T_TIME", MinorType.TIME).addNullable("T_TIMESTAMP", MinorType.TIMESTAMP).addNullable("T_BINARY", MinorType.VARBINARY).addNullable("T_VARBINARY", MinorType.VARBINARY).addNullable("T_BOOLEAN", MinorType.BIT).build();
RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow(U_U_I_D, "apache", "drill", Long.MAX_VALUE, Integer.MAX_VALUE, Short.MAX_VALUE, Byte.MAX_VALUE, Double.MAX_VALUE, Float.MAX_VALUE, BigDecimal.valueOf(10.11), LocalDate.parse("2021-12-12"), LocalTime.parse("12:12:12"), Instant.ofEpochMilli(1639311132000l), "a_b_c_d_e_".getBytes(), "12345".getBytes(), Boolean.TRUE).build();
new RowSetComparison(expected).verifyAndClearAll(sets);
}
use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class SecuredPhoenixDataTypeTest method doTestArrayType.
private void doTestArrayType() throws Exception {
String sql = "select * from phoenix123.v1.arraytype";
QueryBuilder builder = queryBuilder().sql(sql);
RowSet sets = builder.rowSet();
TupleMetadata schema = new SchemaBuilder().addNullable("T_UUID", MinorType.VARCHAR).addArray("T_VARCHAR", MinorType.VARCHAR).addArray("T_CHAR", MinorType.VARCHAR).addArray("T_BIGINT", MinorType.BIGINT).addArray("T_INTEGER", MinorType.INT).addArray("T_DOUBLE", MinorType.FLOAT8).addArray("T_SMALLINT", MinorType.SMALLINT).addArray("T_TINYINT", MinorType.TINYINT).addArray("T_BOOLEAN", MinorType.BIT).build();
RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow(U_U_I_D, strArray("apache", "drill", "1.20"), strArray("a", "b", "c"), longArray(Long.MIN_VALUE, Long.MAX_VALUE), intArray(Integer.MIN_VALUE, Integer.MAX_VALUE), doubleArray(Double.MIN_VALUE, Double.MAX_VALUE), shortArray(Short.MIN_VALUE, Short.MAX_VALUE), byteArray((int) Byte.MIN_VALUE, (int) Byte.MAX_VALUE), boolArray(Boolean.TRUE, Boolean.FALSE)).build();
new RowSetComparison(expected).verifyAndClearAll(sets);
}
use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class TestImageRecordReader method testExplicitQueryWithCompressedFile.
@Test
public void testExplicitQueryWithCompressedFile() throws Exception {
cluster.defineFormat("dfs", "image", new ImageFormatConfig(Arrays.asList("jpg"), false, false, null));
QueryTestUtil.generateCompressedFile("image/LearningApacheDrill.jpg", "zip", "store/image/LearningApacheDrill.jpg.zip");
String sql = "select Format, PixelWidth, PixelHeight, `FileType` from dfs.`store/image/LearningApacheDrill.jpg.zip`";
QueryBuilder builder = client.queryBuilder().sql(sql);
RowSet sets = builder.rowSet();
TupleMetadata schema = new SchemaBuilder().addNullable("Format", MinorType.VARCHAR).addNullable("PixelWidth", MinorType.INT).addNullable("PixelHeight", MinorType.INT).addMap("FileType").addNullable("DetectedFileTypeName", MinorType.VARCHAR).addNullable("DetectedFileTypeLongName", MinorType.VARCHAR).addNullable("DetectedMIMEType", MinorType.VARCHAR).addNullable("ExpectedFileNameExtension", MinorType.VARCHAR).resumeSchema().buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow("JPEG", 800, 800, mapValue("JPEG", "Joint Photographic Experts Group", "image/jpeg", "jpg")).build();
assertEquals(1, sets.rowCount());
new RowSetComparison(expected).verifyAndClearAll(sets);
}
use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class TestImageRecordReader method testTimeZoneOption.
@Test
public void testTimeZoneOption() throws Exception {
cluster.defineFormat("dfs", "image", new ImageFormatConfig(Arrays.asList("psd"), true, false, "UTC"));
String sql = "select ExifIFD0 from dfs.`image/*.psd`";
QueryBuilder builder = client.queryBuilder().sql(sql);
RowSet sets = builder.rowSet();
TupleMetadata schema = new SchemaBuilder().addMap("ExifIFD0").addNullable("Orientation", MinorType.INT).addNullable("XResolution", MinorType.FLOAT8).addNullable("YResolution", MinorType.FLOAT8).addNullable("ResolutionUnit", MinorType.INT).addNullable("Software", MinorType.VARCHAR).addNullable("DateTime", MinorType.TIMESTAMP).resumeSchema().build();
RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow(singleMap(mapValue(1, 72.009, 72.009, 2, "Adobe Photoshop CS2 Windows", Instant.ofEpochMilli(1454717337000L)))).build();
new RowSetComparison(expected).verifyAndClearAll(sets);
}
Aggregations