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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations