use of org.apache.drill.exec.physical.rowSet.RowSetBuilder in project drill by apache.
the class TestPdfFormat method testProvidedSchema.
@Test
public void testProvidedSchema() throws Exception {
String sql = "SELECT * FROM table(cp.`pdf/schools.pdf` (type => 'pdf', combinePages => true, " + "schema => 'inline=(`Last Name` VARCHAR, `First Name Address` VARCHAR, `field_0` VARCHAR, `City` " + "VARCHAR, `State` VARCHAR, `Zip` VARCHAR, `field_1` VARCHAR, `Occupation Employer` VARCHAR, " + "`Date` VARCHAR, `field_2` DATE properties {`drill.format` = `M/d/yyyy`}, `Amount` DOUBLE)')) " + "LIMIT 5";
RowSet results = client.queryBuilder().sql(sql).rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().addNullable("Last Name", MinorType.VARCHAR).addNullable("First Name Address", MinorType.VARCHAR).addNullable("field_0", MinorType.VARCHAR).addNullable("City", MinorType.VARCHAR).addNullable("State", MinorType.VARCHAR).addNullable("Zip", MinorType.VARCHAR).addNullable("field_1", MinorType.VARCHAR).addNullable("Occupation Employer", MinorType.VARCHAR).addNullable("Date", MinorType.VARCHAR).addNullable("field_2", MinorType.DATE).addNullable("Amount", MinorType.FLOAT8).buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow("Lidstad", "Dick & Peg 62 Mississippi River Blvd N", null, "Saint Paul", "MN", null, "55104", "retired", null, LocalDate.parse("2012-10-12"), 60.0).addRow("Strom", "Pam 1229 Hague Ave", null, "St. Paul", "MN", null, "55104", null, null, LocalDate.parse("2012-09-12"), 60.0).addRow("Seeba", "Louise & Paul 1399 Sheldon St", null, "Saint Paul", "MN", null, "55108", "BOE City of Saint Paul", null, LocalDate.parse("2012-10-12"), 60.0).addRow("Schumacher / Bales", "Douglas L. / Patricia 948 County Rd. D W", null, "Saint Paul", "MN", null, "55126", null, null, LocalDate.parse("2012-10-13"), 60.0).addRow("Abrams", "Marjorie 238 8th St east", null, "St Paul", "MN", null, "55101", "Retired Retired", null, LocalDate.parse("2012-08-08"), 75.0).build();
new RowSetComparison(expected).verifyAndClearAll(results);
}
use of org.apache.drill.exec.physical.rowSet.RowSetBuilder in project drill by apache.
the class SplunkPluginTest method verifyIndexes.
@Test
public void verifyIndexes() throws Exception {
String sql = "SHOW TABLES IN `splunk`";
RowSet results = client.queryBuilder().sql(sql).rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().add("TABLE_SCHEMA", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("TABLE_NAME", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow("splunk", "summary").addRow("splunk", "splunklogger").addRow("splunk", "_thefishbucket").addRow("splunk", "_audit").addRow("splunk", "_internal").addRow("splunk", "_introspection").addRow("splunk", "main").addRow("splunk", "history").addRow("splunk", "spl").addRow("splunk", "_telemetry").build();
RowSetUtilities.verify(expected, results);
}
use of org.apache.drill.exec.physical.rowSet.RowSetBuilder in project drill by apache.
the class SplunkPluginTest method testRawSPLQuery.
@Test
@Ignore("the result is not consistent on system tables")
public void testRawSPLQuery() throws Exception {
String sql = "SELECT * FROM splunk.spl WHERE spl = 'search index=_internal earliest=1 latest=now | fieldsummary'";
RowSet results = client.queryBuilder().sql(sql).rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().add("field", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("count", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("distinct_count", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("is_exact", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("max", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("mean", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("min", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("numeric_count", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("stdev", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("values", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow("index", "0", "0", "1", null, null, null, "0", null, "[]").build();
RowSetUtilities.verify(expected, results);
}
use of org.apache.drill.exec.physical.rowSet.RowSetBuilder in project drill by apache.
the class SplunkPluginTest method testExplicitFieldsWithOneFieldLimitQuery.
@Test
public void testExplicitFieldsWithOneFieldLimitQuery() throws Exception {
String sql = "SELECT `component` FROM splunk.`_introspection` ORDER BY `component` LIMIT 2";
RowSet results = client.queryBuilder().sql(sql).rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().add("component", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow("Dispatch").addRow("Fishbucket").build();
RowSetUtilities.verify(expected, results);
}
use of org.apache.drill.exec.physical.rowSet.RowSetBuilder in project drill by apache.
the class SplunkPluginTest method testSingleEqualityFilterQuery.
@Test
@Ignore("the result is not consistent on system tables. The table may be empty before test running")
public void testSingleEqualityFilterQuery() throws Exception {
String sql = "SELECT action, _sourcetype FROM splunk._audit where action='edit'";
RowSet results = client.queryBuilder().sql(sql).rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().add("action", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("_sourcetype", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow("edit", "audittrail").build();
RowSetUtilities.verify(expected, results);
}
Aggregations