Search in sources :

Example 76 with RowSetComparison

use of org.apache.drill.test.rowSet.RowSetComparison 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 77 with RowSetComparison

use of org.apache.drill.test.rowSet.RowSetComparison 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 78 with RowSetComparison

use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.

the class TestHTTPDLogReader method testFlattenMap.

@Test
public void testFlattenMap() throws Exception {
    String sql = "SELECT request_firstline_original_uri_query_came__from " + "FROM  table(cp.`httpd/hackers-access-small.httpd` (type => 'httpd', logFormat => '%h %l %u %t \\\"%r\\\" %s %b \\\"%{Referer}i\\\" " + "\\\"%{User-agent}i\\\"', " + "flattenWildcards => true)) WHERE `request_firstline_original_uri_query_came__from` IS NOT NULL";
    RowSet results = client.queryBuilder().sql(sql).rowSet();
    TupleMetadata expectedSchema = new SchemaBuilder().addNullable("request_firstline_original_uri_query_came__from", MinorType.VARCHAR).build();
    RowSet expected = client.rowSetBuilder(expectedSchema).addRow("http://howto.basjes.nl/join_form").build();
    new RowSetComparison(expected).verifyAndClearAll(results);
}
Also used : 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 79 with RowSetComparison

use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.

the class TestHTTPDLogReader method testImplicitColumn.

@Test
public void testImplicitColumn() throws Exception {
    String sql = "SELECT _raw FROM cp.`httpd/hackers-access-small.httpd`";
    RowSet results = client.queryBuilder().sql(sql).rowSet();
    TupleMetadata expectedSchema = new SchemaBuilder().addNullable("_raw", MinorType.VARCHAR).build();
    RowSet expected = client.rowSetBuilder(expectedSchema).addRow("195.154.46.135 - - [25/Oct/2015:04:11:25 +0100] \"GET /linux/doing-pxe-without-dhcp-control HTTP/1.1\" 200 24323 \"http://howto.basjes.nl/\" \"Mozilla/5.0 (Windows NT 5.1; rv:35.0) Gecko/20100101 Firefox/35.0\"").addRow("23.95.237.180 - - [25/Oct/2015:04:11:26 +0100] \"GET /join_form HTTP/1.0\" 200 11114 \"http://howto.basjes.nl/\" \"Mozilla/5.0 (Windows NT 5.1; rv:35.0) Gecko/20100101 Firefox/35.0\"").addRow("23.95.237.180 - - [25/Oct/2015:04:11:27 +0100] \"POST /join_form HTTP/1.1\" 302 9093 \"http://howto.basjes.nl/join_form\" \"Mozilla/5.0 (Windows NT 5.1; rv:35.0) " + "Gecko/20100101 Firefox/35.0\"").addRow("158.222.5.157 - - [25/Oct/2015:04:24:31 +0100] \"GET /join_form HTTP/1.0\" 200 11114 \"http://howto.basjes.nl/\" \"Mozilla/5.0 (Windows NT 6.3; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 AlexaToolbar/alxf-2.21\"").addRow("158.222.5.157 - - [25/Oct/2015:04:24:32 +0100] \"POST /join_form HTTP/1.1\" 302 9093 \"http://howto.basjes.nl/join_form\" \"Mozilla/5.0 (Windows NT 6.3; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 AlexaToolbar/alxf-2.21\"").addRow("158.222.5.157 - - [25/Oct/2015:04:24:37 +0100] \"GET /acl_users/credentials_cookie_auth/require_login?came_from=http%3A//howto.basjes.nl/join_form HTTP/1.1\" 200 10716 \"http://howto.basjes.nl/join_form\" \"Mozilla/5.0 (Windows NT 6.3; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 AlexaToolbar/alxf-2.21\"").addRow("158.222.5.157 - - [25/Oct/2015:04:24:39 +0100] \"GET /login_form HTTP/1.1\" 200 10543 \"http://howto.basjes.nl/\" \"Mozilla/5.0 (Windows NT 6.3; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 AlexaToolbar/alxf-2.21\"").addRow("158.222.5.157 - - [25/Oct/2015:04:24:41 +0100] \"POST /login_form HTTP/1.1\" 200 16810 \"http://howto.basjes.nl/login_form\" \"Mozilla/5.0 (Windows NT 6.3; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 AlexaToolbar/alxf-2.21\"").addRow("5.39.5.5 - - [25/Oct/2015:04:32:22 +0100] \"GET /join_form HTTP/1.1\" 200 11114 \"http://howto.basjes.nl/\" \"Mozilla/5.0 (Windows NT 5.1; rv:34.0) Gecko/20100101 Firefox/34.0\"").addRow("180.180.64.16 - - [25/Oct/2015:04:34:37 +0100] \"GET /linux/doing-pxe-without-dhcp-control HTTP/1.1\" 200 24323 \"http://howto.basjes.nl/\" \"Mozilla/5.0 (Windows NT 5.1; rv:35.0) Gecko/20100101 Firefox/35.0\"").build();
    new RowSetComparison(expected).verifyAndClearAll(results);
}
Also used : 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 80 with RowSetComparison

use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.

the class TestHTTPDLogReader method testSingleExplicitColumn.

@Test
public void testSingleExplicitColumn() throws Exception {
    String sql = "SELECT request_referer FROM cp.`httpd/hackers-access-small.httpd`";
    RowSet results = client.queryBuilder().sql(sql).rowSet();
    TupleMetadata expectedSchema = new SchemaBuilder().addNullable("request_referer", MinorType.VARCHAR).build();
    RowSet expected = client.rowSetBuilder(expectedSchema).addRow("http://howto.basjes.nl/").addRow("http://howto.basjes.nl/").addRow("http://howto.basjes.nl/join_form").addRow("http://howto.basjes.nl/").addRow("http://howto.basjes.nl/join_form").addRow("http://howto.basjes.nl/join_form").addRow("http://howto.basjes.nl/").addRow("http://howto.basjes.nl/login_form").addRow("http://howto.basjes.nl/").addRow("http://howto.basjes.nl/").build();
    assertEquals(results.rowCount(), 10);
    new RowSetComparison(expected).verifyAndClearAll(results);
}
Also used : 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

RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)289 Test (org.junit.Test)271 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)232 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)211 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)191 RowSetBuilder (org.apache.drill.exec.physical.rowSet.RowSetBuilder)142 ClusterTest (org.apache.drill.test.ClusterTest)138 MockRecordBatch (org.apache.drill.exec.physical.impl.MockRecordBatch)54 SubOperatorTest (org.apache.drill.test.SubOperatorTest)53 QueryBuilder (org.apache.drill.test.QueryBuilder)48 DirectRowSet (org.apache.drill.exec.physical.rowSet.DirectRowSet)42 OperatorTest (org.apache.drill.categories.OperatorTest)38 SingleRowSet (org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet)29 RowSet (org.apache.drill.test.rowSet.RowSet)26 SingleRowSet (org.apache.drill.test.rowSet.RowSet.SingleRowSet)26 SchemaBuilder (org.apache.drill.test.rowSet.schema.SchemaBuilder)25 StreamingAggregate (org.apache.drill.exec.physical.config.StreamingAggregate)19 StreamingAggBatch (org.apache.drill.exec.physical.impl.aggregate.StreamingAggBatch)19 RowSetLoader (org.apache.drill.exec.physical.rowSet.RowSetLoader)18 BatchSchema (org.apache.drill.exec.record.BatchSchema)18