Search in sources :

Example 71 with RowSet

use of org.apache.drill.exec.physical.rowSet.RowSet 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);
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) Ignore(org.junit.Ignore) Test(org.junit.Test) SlowTest(org.apache.drill.categories.SlowTest)

Example 72 with RowSet

use of org.apache.drill.exec.physical.rowSet.RowSet 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);
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) Test(org.junit.Test) SlowTest(org.apache.drill.categories.SlowTest)

Example 73 with RowSet

use of org.apache.drill.exec.physical.rowSet.RowSet 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);
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) Ignore(org.junit.Ignore) Test(org.junit.Test) SlowTest(org.apache.drill.categories.SlowTest)

Example 74 with RowSet

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

the class TestComplexSchemaFunctions method testMapSchemaFunctionWithInnerMap.

@Test
public void testMapSchemaFunctionWithInnerMap() throws RpcException {
    String sql = "SELECT getMapSchema(t1.record.map) AS schema FROM cp.`json/nestedSchema.json` AS t1";
    QueryBuilder q = client.queryBuilder().sql(sql);
    RowSet results = q.rowSet();
    assertEquals(results.rowCount(), 1);
    TupleMetadata expectedSchema = new SchemaBuilder().addMap("schema").addNullable("nested_int_field", MinorType.VARCHAR).addNullable("nested_double_field", MinorType.VARCHAR).addNullable("nested_string_field", MinorType.VARCHAR).resumeSchema().build();
    RowSet expected = client.rowSetBuilder(expectedSchema).addRow((Object) strArray("BIGINT", "FLOAT8", "VARCHAR")).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) QueryBuilder(org.apache.drill.test.QueryBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test) SqlFunctionTest(org.apache.drill.categories.SqlFunctionTest) UnlikelyTest(org.apache.drill.categories.UnlikelyTest)

Example 75 with RowSet

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

the class TestComplexSchemaFunctions method testMapSchemaFunction.

@Test
public void testMapSchemaFunction() throws RpcException {
    String sql = "SELECT getMapSchema(record) AS schema FROM cp.`json/nestedSchema.json`";
    QueryBuilder q = client.queryBuilder().sql(sql);
    RowSet results = q.rowSet();
    assertEquals(results.rowCount(), 1);
    TupleMetadata expectedSchema = new SchemaBuilder().addMap("schema").addNullable("int_field", MinorType.VARCHAR).addNullable("double_field", MinorType.VARCHAR).addNullable("string_field", MinorType.VARCHAR).addNullable("boolean_field", MinorType.VARCHAR).addNullable("int_list", MinorType.VARCHAR).addNullable("double_list", MinorType.VARCHAR).addNullable("boolean_list", MinorType.VARCHAR).addNullable("map", MinorType.VARCHAR).addNullable("repeated_map", MinorType.VARCHAR).resumeSchema().build();
    RowSet expected = client.rowSetBuilder(expectedSchema).addRow((Object) strArray("BIGINT", "FLOAT8", "VARCHAR", "BIT", "REPEATED_BIGINT", "REPEATED_FLOAT8", "REPEATED_BIT", "MAP", "REPEATED_MAP")).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) QueryBuilder(org.apache.drill.test.QueryBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test) SqlFunctionTest(org.apache.drill.categories.SqlFunctionTest) UnlikelyTest(org.apache.drill.categories.UnlikelyTest)

Aggregations

RowSet (org.apache.drill.exec.physical.rowSet.RowSet)725 Test (org.junit.Test)690 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)583 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)574 RowSetBuilder (org.apache.drill.exec.physical.rowSet.RowSetBuilder)297 ClusterTest (org.apache.drill.test.ClusterTest)253 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)233 DirectRowSet (org.apache.drill.exec.physical.rowSet.DirectRowSet)137 SubOperatorTest (org.apache.drill.test.SubOperatorTest)128 JsonTest (org.apache.drill.categories.JsonTest)112 EvfTest (org.apache.drill.categories.EvfTest)107 SingleRowSet (org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet)97 RowSetLoader (org.apache.drill.exec.physical.resultSet.RowSetLoader)63 ResultSetLoader (org.apache.drill.exec.physical.resultSet.ResultSetLoader)61 QueryBuilder (org.apache.drill.test.QueryBuilder)61 MockRecordBatch (org.apache.drill.exec.physical.impl.MockRecordBatch)60 OperatorTest (org.apache.drill.categories.OperatorTest)53 VectorContainer (org.apache.drill.exec.record.VectorContainer)31 RowBatchReader (org.apache.drill.exec.physical.impl.scan.RowBatchReader)28 QuerySummary (org.apache.drill.test.QueryBuilder.QuerySummary)27