@Test public void testParse() throws QuarkException, SQLException { SqlQueryParser parser = new SqlQueryParser(info); RelNode relNode = parser.parse("select * from simple").getRelNode(); List<String> usedTables = parser.getTables(relNode); assertThat(usedTables).contains("TEST.SIMPLE"); }
@Test public void testSemanticError() throws QuarkException, SQLException { SqlQueryParser parser = new SqlQueryParser(info); try { parser.parse( "select count(*) from test.many_colum where " + "test.many_columns.j > 100 and test.many_columns.i = 10"); failBecauseExceptionWasNotThrown(SQLException.class); } catch (SQLException e) { assertThat((Throwable) e).hasMessageContaining("Table 'TEST.MANY_COLUM' not found"); } }
@Test public void testSyntaxError() throws QuarkException, SQLException { SqlQueryParser parser = new SqlQueryParser(info); try { parser.parse( "select count(*) test.many_columns where " + "test.many_columns.j > 100 and test.many_columns.i = 10"); failBecauseExceptionWasNotThrown(SQLException.class); } catch (SQLException e) { assertThat((Throwable) e).hasMessageContaining("Encountered \".\" at line 1, column 21."); } }
@Test public void testFilter() throws QuarkException, SQLException { SqlQueryParser parser = new SqlQueryParser(info); SqlQueryParser.SqlQueryParserResult result = parser.parse("select count(*) from test.many_columns where many_columns.j > 100"); List<String> usedTables = parser.getTables(result.getRelNode()); assertThat(usedTables).contains("TEST.MANY_COLUMNS"); assertThat( result.getParsedSql().equals("SELECT COUNT(*) FROM TEST.MANY_COLUMNS WHERE J > 100")); }