use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class TestSpssReader method testExplicitQuery.
@Test
public void testExplicitQuery() throws Exception {
String sql = "SELECT ID, Urban, Urban_value FROM dfs.`spss/testdata.sav` WHERE d16=4";
QueryBuilder q = client.queryBuilder().sql(sql);
RowSet results = q.rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().addNullable("ID", TypeProtos.MinorType.FLOAT8).addNullable("Urban", TypeProtos.MinorType.FLOAT8).addNullable("Urban_value", TypeProtos.MinorType.VARCHAR).buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow(47.0, 1.0, "Urban").addRow(53.0, 1.0, "Urban").addRow(66.0, 1.0, "Urban").build();
assertEquals(3, results.rowCount());
new RowSetComparison(expected).verifyAndClearAll(results);
}
use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class TestSpssReader method testStarQuery.
@Test
public void testStarQuery() throws Exception {
String sql = "SELECT * FROM dfs.`spss/testdata.sav` WHERE d16=4";
QueryBuilder q = client.queryBuilder().sql(sql);
RowSet results = q.rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().addNullable("ID", TypeProtos.MinorType.FLOAT8).addNullable("Urban", TypeProtos.MinorType.FLOAT8).addNullable("Urban_value", TypeProtos.MinorType.VARCHAR).addNullable("District", TypeProtos.MinorType.FLOAT8).addNullable("District_value", TypeProtos.MinorType.VARCHAR).addNullable("Province", TypeProtos.MinorType.FLOAT8).addNullable("Province_value", TypeProtos.MinorType.VARCHAR).addNullable("Interviewer", TypeProtos.MinorType.FLOAT8).addNullable("Date", TypeProtos.MinorType.FLOAT8).addNullable("d6_1", TypeProtos.MinorType.FLOAT8).addNullable("d6_1_Value", TypeProtos.MinorType.VARCHAR).addNullable("d6_2", TypeProtos.MinorType.FLOAT8).addNullable("d6_2_Value", TypeProtos.MinorType.VARCHAR).addNullable("d6_3", TypeProtos.MinorType.FLOAT8).addNullable("d6_3_Value", TypeProtos.MinorType.VARCHAR).addNullable("d6_4", TypeProtos.MinorType.FLOAT8).addNullable("d6_4_Value", TypeProtos.MinorType.VARCHAR).addNullable("s_1", TypeProtos.MinorType.VARCHAR).addNullable("d6_5", TypeProtos.MinorType.FLOAT8).addNullable("d6_5_Value", TypeProtos.MinorType.VARCHAR).addNullable("d6_6", TypeProtos.MinorType.FLOAT8).addNullable("d6_6_Value", TypeProtos.MinorType.VARCHAR).addNullable("d6_7", TypeProtos.MinorType.FLOAT8).addNullable("d6_7_Value", TypeProtos.MinorType.VARCHAR).addNullable("q1", TypeProtos.MinorType.FLOAT8).addNullable("q1_Value", TypeProtos.MinorType.VARCHAR).addNullable("q2", TypeProtos.MinorType.FLOAT8).addNullable("q2_Value", TypeProtos.MinorType.VARCHAR).addNullable("d7a", TypeProtos.MinorType.FLOAT8).addNullable("d7a_Value", TypeProtos.MinorType.VARCHAR).addNullable("d7b", TypeProtos.MinorType.FLOAT8).addNullable("d7b_Value", TypeProtos.MinorType.VARCHAR).addNullable("d16", TypeProtos.MinorType.FLOAT8).addNullable("Stratum", TypeProtos.MinorType.FLOAT8).addNullable("S1_IP", TypeProtos.MinorType.FLOAT8).addNullable("S2_IP", TypeProtos.MinorType.FLOAT8).addNullable("Sample_Weight", TypeProtos.MinorType.FLOAT8).buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow(47.0, 1.0, "Urban", 101.0, "Kabul", 1.0, "Kabul", 151.0, 1.34557632E10, 1.0, "Yes", 2.0, "No", 2.0, "No", 2.0, "No", "", 2.0, "No", 2.0, "No", 2.0, "No", 1.0, "Good", 2.0, "The same", 5.0, "Housewife (not working outside of the home)", 97.0, "Not Asked", 4.0, 121.0, 0.007463305415042708, 0.006666666666666667, 20098.33333333333).addRow(53.0, 1.0, "Urban", 101.0, "Kabul", 1.0, "Kabul", 151.0, 1.34557632E10, 1.0, "Yes", 2.0, "No", 2.0, "No", 2.0, "No", "", 2.0, "No", 2.0, "No", 2.0, "No", 1.0, "Good", 2.0, "The same", 5.0, "Housewife (not working outside of the home)", 97.0, "Not Asked", 4.0, 121.0, 0.007463305415042708, 0.006666666666666667, 20098.33333333333).addRow(66.0, 1.0, "Urban", 101.0, "Kabul", 1.0, "Kabul", 774.0, 1.34556768E10, 2.0, "No", 1.0, "Yes", 1.0, "Yes", 2.0, "No", "", 2.0, "No", 2.0, "No", 2.0, "No", 1.0, "Good", 1.0, "Better", 1.0, "Working full time", 13.0, "Private Business Sole Proprietor", 4.0, 111.0, 0.017389288198469743, 0.006666666666666667, 8626.0).build();
assertEquals(3, results.rowCount());
new RowSetComparison(expected).verifyAndClearAll(results);
}
use of org.apache.drill.test.rowSet.RowSetComparison 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);
}
use of org.apache.drill.test.rowSet.RowSetComparison 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);
}
use of org.apache.drill.test.rowSet.RowSetComparison 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);
}
Aggregations