Search in sources :

Example 86 with RowSetBuilder

use of org.apache.drill.exec.physical.rowSet.RowSetBuilder 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 87 with RowSetBuilder

use of org.apache.drill.exec.physical.rowSet.RowSetBuilder 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)

Example 88 with RowSetBuilder

use of org.apache.drill.exec.physical.rowSet.RowSetBuilder in project drill by apache.

the class TestImageRecordReader method testFileSystemMetadataOption.

@Test
public void testFileSystemMetadataOption() throws Exception {
    cluster.defineFormat("dfs", "image", new ImageFormatConfig(Arrays.asList("gif"), true, false, null));
    String sql = "select FileSize, Format, PixelWidth, PixelHeight, ColorMode, BitsPerPixel," + " Orientation, DPIWidth, DPIHeight, HasAlpha, Duration, VideoCodec, FrameRate, AudioCodec," + " AudioSampleSize, AudioSampleRate from dfs.`image/*.gif`";
    QueryBuilder builder = client.queryBuilder().sql(sql);
    RowSet sets = builder.rowSet();
    TupleMetadata schema = new SchemaBuilder().addNullable("FileSize", MinorType.BIGINT).addNullable("Format", MinorType.VARCHAR).addNullable("PixelWidth", MinorType.INT).addNullable("PixelHeight", MinorType.INT).addNullable("ColorMode", MinorType.VARCHAR).addNullable("BitsPerPixel", MinorType.INT).addNullable("Orientation", MinorType.INT).addNullable("DPIWidth", MinorType.FLOAT8).addNullable("DPIHeight", MinorType.FLOAT8).addNullable("HasAlpha", MinorType.BIT).addNullable("Duration", MinorType.BIGINT).addNullable("VideoCodec", MinorType.VARCHAR).addNullable("FrameRate", MinorType.FLOAT8).addNullable("AudioCodec", MinorType.VARCHAR).addNullable("AudioSampleSize", MinorType.INT).addNullable("AudioSampleRate", MinorType.FLOAT8).build();
    RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow(10463, "GIF", 128, 174, "Indexed", 8, 0, 0.0, 0.0, true, 0, "Unknown", 0.0, "Unknown", 0, 0.0).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)

Example 89 with RowSetBuilder

use of org.apache.drill.exec.physical.rowSet.RowSetBuilder in project drill by apache.

the class TestHTTPDLogReader method testExplicitSomeQueryWithCompressedFile.

@Test
public void testExplicitSomeQueryWithCompressedFile() throws Exception {
    generateCompressedFile("httpd/hackers-access-small.httpd", "zip", "httpd/hackers-access-small.httpd.zip");
    String sql = "SELECT request_referer_ref, request_receive_time_last_time, request_firstline_uri_protocol FROM dfs.`httpd/hackers-access-small.httpd.zip`";
    RowSet results = client.queryBuilder().sql(sql).rowSet();
    TupleMetadata expectedSchema = new SchemaBuilder().addNullable("request_referer_ref", MinorType.VARCHAR).addNullable("request_receive_time_last_time", MinorType.TIME).addNullable("request_firstline_uri_protocol", MinorType.VARCHAR).buildSchema();
    RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow(null, LocalTime.parse("04:11:25"), null).addRow(null, LocalTime.parse("04:11:26"), null).addRow(null, LocalTime.parse("04:11:27"), null).addRow(null, LocalTime.parse("04:24:31"), null).addRow(null, LocalTime.parse("04:24:32"), null).addRow(null, LocalTime.parse("04:24:37"), null).addRow(null, LocalTime.parse("04:24:39"), null).addRow(null, LocalTime.parse("04:24:41"), null).addRow(null, LocalTime.parse("04:32:22"), null).addRow(null, LocalTime.parse("04:34:37"), null).build();
    new RowSetComparison(expected).verifyAndClearAll(results);
}
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) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 90 with RowSetBuilder

use of org.apache.drill.exec.physical.rowSet.RowSetBuilder in project drill by apache.

the class TestHDF5Format method test1DFlattenScalarQuery.

@Test
public void test1DFlattenScalarQuery() throws Exception {
    String sql = "SELECT * FROM table(dfs.`hdf5/scalar.h5` (type => 'hdf5', defaultPath => '/nd/1D')) WHERE `1D` < 5";
    RowSet results = client.queryBuilder().sql(sql).rowSet();
    TupleMetadata expectedSchema = new SchemaBuilder().add("1D", MinorType.INT, DataMode.OPTIONAL).buildSchema();
    RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow(-2147483648).addRow(1).addRow(2).addRow(3).addRow(4).build();
    new RowSetComparison(expected).unorderedVerifyAndClearAll(results);
}
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) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Aggregations

RowSetBuilder (org.apache.drill.exec.physical.rowSet.RowSetBuilder)303 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)296 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)293 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)288 Test (org.junit.Test)282 ClusterTest (org.apache.drill.test.ClusterTest)153 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)140 DirectRowSet (org.apache.drill.exec.physical.rowSet.DirectRowSet)84 EvfTest (org.apache.drill.categories.EvfTest)64 QueryBuilder (org.apache.drill.test.QueryBuilder)45 SingleRowSet (org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet)28 SubOperatorTest (org.apache.drill.test.SubOperatorTest)27 QuerySummary (org.apache.drill.test.QueryBuilder.QuerySummary)26 SlowTest (org.apache.drill.categories.SlowTest)23 ValueVector (org.apache.drill.exec.vector.ValueVector)23 MockResponse (okhttp3.mockwebserver.MockResponse)21 MockWebServer (okhttp3.mockwebserver.MockWebServer)21 ColumnSize (org.apache.drill.exec.record.RecordBatchSizer.ColumnSize)20 RepeatedValueVector (org.apache.drill.exec.vector.complex.RepeatedValueVector)18 JdbcStorageTest (org.apache.drill.categories.JdbcStorageTest)17