Search in sources :

Example 71 with RowSetBuilder

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

the class TestSyslogFormat method testStructuredDataQuery.

@Test
public void testStructuredDataQuery() throws Exception {
    String sql = "SELECT syslog_data.`structured_data`.`UserAgent` AS UserAgent, " + "syslog_data.`structured_data`.`UserHostAddress` AS UserHostAddress," + "syslog_data.`structured_data`.`BrowserSession` AS BrowserSession," + "syslog_data.`structured_data`.`Realm` AS Realm," + "syslog_data.`structured_data`.`Appliance` AS Appliance," + "syslog_data.`structured_data`.`Company` AS Company," + "syslog_data.`structured_data`.`UserID` AS UserID," + "syslog_data.`structured_data`.`PEN` AS PEN," + "syslog_data.`structured_data`.`HostName` AS HostName," + "syslog_data.`structured_data`.`Category` AS Category," + "syslog_data.`structured_data`.`Priority` AS Priority " + "FROM (" + "SELECT structured_data " + "FROM cp.`syslog/test.syslog`" + ") AS syslog_data";
    RowSet results = client.queryBuilder().sql(sql).rowSet();
    TupleMetadata expectedSchema = new SchemaBuilder().add("UserAgent", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("UserHostAddress", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("BrowserSession", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("Realm", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("Appliance", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("Company", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("UserID", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("PEN", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("HostName", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("Category", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("Priority", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).buildSchema();
    RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow("Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko", "192.168.2.132", "0gvhdi5udjuqtweprbgoxilc", "SecureAuth0", "secureauthqa.gosecureauth.com", "SecureAuth Corporation", "Tester2", "27389", "192.168.2.132", "AUDIT", "4").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 72 with RowSetBuilder

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

the class TestSyslogFormat method testStarQuery.

@Test
public void testStarQuery() throws Exception {
    String sql = "SELECT * FROM cp.`syslog/logs1.syslog`";
    RowSet results = client.queryBuilder().sql(sql).rowSet();
    TupleMetadata expectedSchema = new SchemaBuilder().add("event_date", TypeProtos.MinorType.TIMESTAMP, TypeProtos.DataMode.OPTIONAL).add("severity_code", TypeProtos.MinorType.INT, TypeProtos.DataMode.OPTIONAL).add("facility_code", TypeProtos.MinorType.INT, TypeProtos.DataMode.OPTIONAL).add("severity", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("facility", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("ip", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("app_name", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("process_id", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("message_id", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("structured_data_text", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("structured_data", MinorType.MAP, DataMode.REQUIRED).add("message", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).buildSchema();
    RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow(1065910455003L, 2, 4, "CRIT", "AUTH", "mymachine.example.com", "su", null, "ID47", null, mapArray(), "BOM'su root' failed for lonvick on /dev/pts/8").addRow(482196050520L, 2, 4, "CRIT", "AUTH", "mymachine.example.com", "su", null, "ID47", null, mapArray(), "BOM'su root' failed for lonvick on /dev/pts/8").addRow(482196050520L, 2, 4, "CRIT", "AUTH", "mymachine.example.com", "su", null, "ID47", null, mapArray(), "BOM'su root' failed for lonvick on /dev/pts/8").addRow(1065910455003L, 2, 4, "CRIT", "AUTH", "mymachine.example.com", "su", null, "ID47", null, mapArray(), "BOM'su root' failed for lonvick on /dev/pts/8").addRow(1061727255000L, 2, 4, "CRIT", "AUTH", "mymachine.example.com", "su", null, "ID47", null, mapArray(), "BOM'su root' failed for lonvick on /dev/pts/8").addRow(1061727255000L, 5, 20, "NOTICE", "LOCAL4", "192.0.2.1", "myproc", "8710", null, null, mapArray(), "%% It's time to make the do-nuts.").build();
    assertEquals(6, results.rowCount());
    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 73 with RowSetBuilder

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

the class TestSyslogFormat method testStarFlattenedStructuredDataQuery.

@Test
public void testStarFlattenedStructuredDataQuery() throws Exception {
    String sql = "SELECT * FROM cp.`syslog/test.syslog1`";
    RowSet results = client.queryBuilder().sql(sql).rowSet();
    TupleMetadata expectedSchema = new SchemaBuilder().add("event_date", TypeProtos.MinorType.TIMESTAMP, TypeProtos.DataMode.OPTIONAL).add("severity_code", TypeProtos.MinorType.INT, TypeProtos.DataMode.OPTIONAL).add("facility_code", TypeProtos.MinorType.INT, TypeProtos.DataMode.OPTIONAL).add("severity", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("facility", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("ip", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("app_name", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("process_id", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("message_id", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("structured_data_text", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("message", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("structured_data_UserAgent", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("structured_data_UserHostAddress", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("structured_data_BrowserSession", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("structured_data_Realm", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("structured_data_Appliance", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("structured_data_Company", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("structured_data_UserID", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("structured_data_PEN", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("structured_data_HostName", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("structured_data_Category", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("structured_data_Priority", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).buildSchema();
    RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow(1438811939693L, 6, 10, "INFO", "AUTHPRIV", "192.168.2.132", "SecureAuth0", "23108", "ID52020", "{SecureAuth@27389=[UserAgent=Mozilla/5.0 (Windows NT 6.1; WOW64; " + "Trident/7.0; rv:11.0) like Gecko, UserHostAddress=192.168.2.132, BrowserSession=0gvhdi5udjuqtweprbgoxilc, Realm=SecureAuth0, Appliance=secureauthqa.gosecureauth.com, " + "Company=SecureAuth Corporation, UserID=Tester2, PEN=27389, HostName=192.168.2.132, Category=AUDIT, Priority=4]}", "Found the user for retrieving user's profile", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko", "192.168.2.132", "0gvhdi5udjuqtweprbgoxilc", "SecureAuth0", "secureauthqa.gosecureauth.com", "SecureAuth Corporation", "Tester2", "27389", "192.168.2.132", "AUDIT", "4").addRow(1459529040580L, 6, 16, "INFO", "LOCAL0", "MacBook-Pro-3", null, "94473", null, null, "{\"pid\":94473,\"hostname\":\"MacBook-Pro-3\",\"level\":30,\"msg\":\"hello world\",\"time\":1459529098958,\"v\":1}", null, null, null, null, null, null, null, null, null, null, null).build();
    assertEquals(2, results.rowCount());
    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 74 with RowSetBuilder

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

the class TestSyslogFormat method testNonComplexFieldsWithCompressedFile.

@Test
public void testNonComplexFieldsWithCompressedFile() throws Exception {
    generateCompressedFile("syslog/logs.syslog", "zip", "syslog/logs.syslog.zip");
    String sql = "SELECT event_date," + "severity_code," + "severity," + "facility_code," + "facility," + "ip," + "process_id," + "message_id," + "structured_data_text " + "FROM dfs.`syslog/logs.syslog.zip`";
    RowSet results = client.queryBuilder().sql(sql).rowSet();
    TupleMetadata expectedSchema = new SchemaBuilder().add("event_date", TypeProtos.MinorType.TIMESTAMP, TypeProtos.DataMode.OPTIONAL).add("severity_code", TypeProtos.MinorType.INT, TypeProtos.DataMode.OPTIONAL).add("severity", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("facility_code", TypeProtos.MinorType.INT, TypeProtos.DataMode.OPTIONAL).add("facility", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("ip", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("process_id", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("message_id", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("structured_data_text", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).buildSchema();
    RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow(1065910455003L, 2, "CRIT", 4, "AUTH", "mymachine.example.com", null, "ID47", null).addRow(482196050520L, 2, "CRIT", 4, "AUTH", "mymachine.example.com", null, "ID47", null).addRow(482196050520L, 2, "CRIT", 4, "AUTH", "mymachine.example.com", null, "ID47", null).addRow(1065910455003L, 2, "CRIT", 4, "AUTH", "mymachine.example.com", null, "ID47", null).addRow(1061727255000L, 2, "CRIT", 4, "AUTH", "mymachine.example.com", null, "ID47", null).addRow(1061727255000L, 5, "NOTICE", 20, "LOCAL4", "192.0.2.1", "8710", null, null).addRow(1065910455003L, 5, "NOTICE", 20, "LOCAL4", "mymachine.example.com", null, "ID47", "{examplePriority@32473=[class=high], exampleSDID@32473=[iut=3, " + "eventSource=Application, eventID=1011]}").addRow(1065910455003L, 5, "NOTICE", 20, "LOCAL4", "mymachine.example.com", null, "ID47", "{examplePriority@32473=[class=high], exampleSDID@32473=[iut=3, " + "eventSource=Application, eventID=1011]}").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 75 with RowSetBuilder

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

the class PhoenixSQLTest method testHavingPushdown.

@Test
public void testHavingPushdown() throws Exception {
    String sql = "select n_regionkey, max(n_nationkey) from phoenix123.v1.nation group by n_regionkey having max(n_nationkey) > 20";
    QueryBuilder builder = client.queryBuilder().sql(sql);
    RowSet sets = builder.rowSet();
    builder.planMatcher().exclude("Aggregate").include("Phoenix\\(.* GROUP BY .* HAVING MAX").match();
    TupleMetadata schema = new SchemaBuilder().addNullable("n_regionkey", MinorType.BIGINT).addNullable("EXPR$1", MinorType.BIGINT).build();
    RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow(1, 24).addRow(2, 21).addRow(3, 23).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)

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