Search in sources :

Example 26 with QueryBuilder

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);
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) RowSetComparison(org.apache.drill.test.rowSet.RowSetComparison) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) QueryBuilder(org.apache.drill.test.QueryBuilder) Test(org.junit.Test) SlowTest(org.apache.drill.categories.SlowTest)

Example 27 with QueryBuilder

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);
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) RowSetComparison(org.apache.drill.test.rowSet.RowSetComparison) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) QueryBuilder(org.apache.drill.test.QueryBuilder)

Example 28 with QueryBuilder

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);
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) RowSetComparison(org.apache.drill.test.rowSet.RowSetComparison) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) QueryBuilder(org.apache.drill.test.QueryBuilder)

Example 29 with QueryBuilder

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);
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) RowSetComparison(org.apache.drill.test.rowSet.RowSetComparison) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) QueryBuilder(org.apache.drill.test.QueryBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 30 with QueryBuilder

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);
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) RowSetComparison(org.apache.drill.test.rowSet.RowSetComparison) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) QueryBuilder(org.apache.drill.test.QueryBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Aggregations

QueryBuilder (org.apache.drill.test.QueryBuilder)65 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)61 Test (org.junit.Test)53 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)48 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)48 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)48 RowSetBuilder (org.apache.drill.exec.physical.rowSet.RowSetBuilder)45 ClusterTest (org.apache.drill.test.ClusterTest)39 SlowTest (org.apache.drill.categories.SlowTest)14 SqlFunctionTest (org.apache.drill.categories.SqlFunctionTest)3 UnlikelyTest (org.apache.drill.categories.UnlikelyTest)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 Ignore (org.junit.Ignore)2 EvfTest (org.apache.drill.categories.EvfTest)1 SqlTest (org.apache.drill.categories.SqlTest)1 BaseCsvTest (org.apache.drill.exec.store.easy.text.compliant.BaseCsvTest)1 Disabled (org.junit.jupiter.api.Disabled)1 Test (org.junit.jupiter.api.Test)1