use of org.apache.drill.test.QueryBuilder.QuerySummary in project drill by apache.
the class TestJdbcWriterWithH2 method testCTASFromFileWithNulls.
@Test
public void testCTASFromFileWithNulls() throws Exception {
String sql = String.format("CREATE TABLE %s AS SELECT int_field, float_field, varchar_field, boolean_field FROM cp.`json/dataTypes.json`", TEST_TABLE);
QuerySummary insertResults = queryBuilder().sql(sql).run();
assertTrue(insertResults.succeeded());
try {
sql = String.format("SELECT * FROM %s", TEST_TABLE);
DirectRowSet results = queryBuilder().sql(sql).rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().addNullable("int_field", MinorType.BIGINT, 38).addNullable("float_field", MinorType.FLOAT8, 38).addNullable("varchar_field", MinorType.VARCHAR, 38).addNullable("boolean_field", MinorType.BIT, 1).build();
RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow(1L, 1.0, "foo1", true).addRow(null, null, null, null).addRow(2L, 2.0, "foo2", false).build();
RowSetUtilities.verify(expected, results);
} finally {
QuerySummary dropResults = queryBuilder().sql(DROP_TEST_TABLE).run();
assertTrue(dropResults.succeeded());
}
}
use of org.apache.drill.test.QueryBuilder.QuerySummary in project drill by apache.
the class TestJdbcWriterWithH2 method testBasicCTASIfNotExists.
@Test
public void testBasicCTASIfNotExists() throws Exception {
String query = String.format("CREATE TABLE IF NOT EXISTS %s (ID, NAME) AS SELECT * FROM (VALUES(1,2), (3,4))", TEST_TABLE);
// Create the table and insert the values
QuerySummary insertResults = queryBuilder().sql(query).run();
assertTrue(insertResults.succeeded());
try {
// Query the table to see if the insertion was successful
String testQuery = String.format("SELECT * FROM %s", TEST_TABLE);
DirectRowSet results = queryBuilder().sql(testQuery).rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().add("ID", MinorType.BIGINT, DataMode.OPTIONAL).add("NAME", MinorType.BIGINT, DataMode.OPTIONAL).buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow(1L, 2L).addRow(3L, 4L).build();
RowSetUtilities.verify(expected, results);
} finally {
QuerySummary dropResults = queryBuilder().sql(DROP_TEST_TABLE).run();
assertTrue(dropResults.succeeded());
}
}
use of org.apache.drill.test.QueryBuilder.QuerySummary in project drill by apache.
the class TestPdfFormat method testFileWithNoTables.
@Test
public void testFileWithNoTables() throws Exception {
String sql = "SELECT * FROM table(cp.`pdf/labor.pdf` (type => 'pdf', extractionAlgorithm => 'spreadsheet'))";
QuerySummary results = client.queryBuilder().sql(sql).run();
assertEquals(1, results.recordCount());
}
use of org.apache.drill.test.QueryBuilder.QuerySummary in project drill by apache.
the class TestPdfFormat method testPageMerge.
@Test
public void testPageMerge() throws Exception {
String sql = "SELECT * FROM table(cp.`pdf/schools.pdf` (type => 'pdf', combinePages => true, extractHeaders=> true))";
QuerySummary results = client.queryBuilder().sql(sql).run();
assertEquals(221, results.recordCount());
}
Aggregations