@BeforeClass public void init() { h2QueryRunner = new H2QueryRunner(); }
protected MaterializedResult computeExpected(@Language("SQL") String sql, List<? extends Type> resultTypes) { return h2QueryRunner.execute(getSession(), sql, resultTypes); }
@AfterClass(alwaysRun = true) public void close() { h2QueryRunner.close(); h2QueryRunner = null; }
")"); handle.execute("CREATE INDEX custkey_index ON orders (custkey)"); insertRows(tpchMetadata, ORDERS); " PRIMARY KEY (orderkey, linenumber)" + ")"); insertRows(tpchMetadata, LINE_ITEM); " comment VARCHAR(114) NOT NULL\n" + ")"); insertRows(tpchMetadata, NATION); " comment VARCHAR(115) NOT NULL\n" + ")"); insertRows(tpchMetadata, REGION); " comment VARCHAR(23) NOT NULL\n" + ")"); insertRows(tpchMetadata, PART);
public MaterializedResult execute(Session session, @Language("SQL") String sql, List<? extends Type> resultTypes) { MaterializedResult materializedRows = new MaterializedResult( handle.setSqlParser(new RawSqlParser()) .setTemplateEngine((template, context) -> template) .createQuery(sql) .map(rowMapper(resultTypes)) .list(), resultTypes); return materializedRows; }
private void insertRows(TpchMetadata tpchMetadata, TpchTable tpchTable) { TpchTableHandle tableHandle = tpchMetadata.getTableHandle(null, new SchemaTableName(TINY_SCHEMA_NAME, tpchTable.getTableName())); insertRows(tpchMetadata.getTableMetadata(null, tableHandle), handle, createTpchRecordSet(tpchTable, tableHandle.getScaleFactor())); }
public MaterializedResult execute(Session session, @Language("SQL") String sql, List<? extends Type> resultTypes) { MaterializedResult materializedRows = new MaterializedResult( handle.setSqlParser(new RawSqlParser()) .setTemplateEngine((template, context) -> template) .createQuery(sql) .map(rowMapper(resultTypes)) .list(), resultTypes); return materializedRows; }
@Test public void testDateToTimestampCoercion() { // allow running tests with a connector that supports TIMESTAMP but not DATE // ordinary date MaterializedResult rows = h2QueryRunner.execute(TEST_SESSION, "SELECT DATE '2018-01-13'", ImmutableList.of(TIMESTAMP)); assertEquals(rows.getOnlyValue(), LocalDate.of(2018, 1, 13).atStartOfDay()); // date, which midnight was skipped in JVM zone LocalDate forwardOffsetChangeAtMidnightInJvmZone = LocalDate.of(1970, 1, 1); checkState(ZoneId.systemDefault().getRules().getValidOffsets(forwardOffsetChangeAtMidnightInJvmZone.atStartOfDay()).size() == 0, "This test assumes certain JVM time zone"); rows = h2QueryRunner.execute(TEST_SESSION, DateTimeFormatter.ofPattern("'SELECT DATE '''uuuu-MM-dd''").format(forwardOffsetChangeAtMidnightInJvmZone), ImmutableList.of(TIMESTAMP)); assertEquals(rows.getOnlyValue(), forwardOffsetChangeAtMidnightInJvmZone.atStartOfDay()); } }
@BeforeClass public void init() throws Exception { queryRunner = queryRunnerSupplier.get(); h2QueryRunner = new H2QueryRunner(); sqlParser = new SqlParser(); }
")"); handle.execute("CREATE INDEX custkey_index ON orders (custkey)"); insertRows(tpchMetadata, ORDERS); " PRIMARY KEY (orderkey, linenumber)" + ")"); insertRows(tpchMetadata, LINE_ITEM); " comment VARCHAR(114) NOT NULL\n" + ")"); insertRows(tpchMetadata, NATION); " comment VARCHAR(115) NOT NULL\n" + ")"); insertRows(tpchMetadata, REGION); " comment VARCHAR(23) NOT NULL\n" + ")"); insertRows(tpchMetadata, PART);
@AfterClass(alwaysRun = true) public void close() { h2QueryRunner.close(); h2QueryRunner = null; }
MaterializedResult expectedResults = null; try { expectedResults = h2QueryRunner.execute(session, expected, actualResults.getTypes());
@BeforeClass public void init() throws Exception { queryRunner = queryRunnerSupplier.get(); h2QueryRunner = new H2QueryRunner(); sqlParser = new SqlParser(); }
private void insertRows(TpchMetadata tpchMetadata, TpchTable tpchTable) { TpchTableHandle tableHandle = tpchMetadata.getTableHandle(null, new SchemaTableName(TINY_SCHEMA_NAME, tpchTable.getTableName())); insertRows(tpchMetadata.getTableMetadata(null, tableHandle), handle, createTpchRecordSet(tpchTable, tableHandle.getScaleFactor())); }
protected MaterializedResult computeExpected(@Language("SQL") String sql, List<? extends Type> resultTypes) { return h2QueryRunner.execute(getSession(), sql, resultTypes); }
@BeforeClass public void init() { h2QueryRunner = new H2QueryRunner(); }
@Test public void testDateToTimestampCoercion() { // allow running tests with a connector that supports TIMESTAMP but not DATE // ordinary date MaterializedResult rows = h2QueryRunner.execute(TEST_SESSION, "SELECT DATE '2018-01-13'", ImmutableList.of(TIMESTAMP)); assertEquals(rows.getOnlyValue(), LocalDate.of(2018, 1, 13).atStartOfDay()); // date, which midnight was skipped in JVM zone LocalDate forwardOffsetChangeAtMidnightInJvmZone = LocalDate.of(1970, 1, 1); checkState(ZoneId.systemDefault().getRules().getValidOffsets(forwardOffsetChangeAtMidnightInJvmZone.atStartOfDay()).size() == 0, "This test assumes certain JVM time zone"); rows = h2QueryRunner.execute(TEST_SESSION, DateTimeFormatter.ofPattern("'SELECT DATE '''uuuu-MM-dd''").format(forwardOffsetChangeAtMidnightInJvmZone), ImmutableList.of(TIMESTAMP)); assertEquals(rows.getOnlyValue(), forwardOffsetChangeAtMidnightInJvmZone.atStartOfDay()); } }
MaterializedResult expectedResults = null; try { expectedResults = h2QueryRunner.execute(session, expected, actualResults.getTypes());