use of org.apache.drill.exec.planner.sql.parser.CompoundIdentifierConverter in project drill by axbaretto.
the class TestSqlBracketlessSyntax method checkComplexExpressionParsing.
@Test
public void checkComplexExpressionParsing() throws Exception {
FrameworkConfig config = //
Frameworks.newConfigBuilder().parserConfig(SqlParser.configBuilder().setLex(Lex.MYSQL).setIdentifierMaxLength(PlannerSettings.DEFAULT_IDENTIFIER_MAX_LENGTH).setParserFactory(DrillParserImpl.FACTORY).build()).defaultSchema(//
CalciteSchema.createRootSchema(false, false).plus()).convertletTable(//
DrillConvertletTable.INSTANCE).build();
Planner planner = Frameworks.getPlanner(config);
SqlNode node = planner.parse("" + "select a[4].c \n" + "from x.y.z \n" + "where a.c.b = 5 and x[2] = 7 \n" + "group by d \n" + "having a.c < 5 \n" + "order by x.a.a.a.a.a");
String expected = "SELECT `a`[4]['c']\n" + "FROM `x`.`y`.`z`\n" + "WHERE `a`.`c`['b'] = 5 AND `x`[2] = 7\n" + "GROUP BY `d`\n" + "HAVING `a`.`c` < 5\n" + "ORDER BY `x`.`a`['a']['a']['a']['a']";
SqlNode rewritten = node.accept(new CompoundIdentifierConverter());
String rewrittenQuery = rewritten.toString();
DrillAssert.assertMultiLineStringEquals(expected, rewrittenQuery);
}
use of org.apache.drill.exec.planner.sql.parser.CompoundIdentifierConverter in project drill by apache.
the class TestSqlBracketlessSyntax method checkComplexExpressionParsing.
@Test
public void checkComplexExpressionParsing() throws Exception {
FrameworkConfig config = //
Frameworks.newConfigBuilder().parserConfig(SqlParser.configBuilder().setLex(Lex.MYSQL).setIdentifierMaxLength(PlannerSettings.DEFAULT_IDENTIFIER_MAX_LENGTH).setParserFactory(DrillParserImpl.FACTORY).build()).defaultSchema(//
CalciteSchema.createRootSchema(false, false).plus()).convertletTable(//
DrillConvertletTable.INSTANCE).build();
Planner planner = Frameworks.getPlanner(config);
SqlNode node = planner.parse("" + "select a[4].c \n" + "from x.y.z \n" + "where a.c.b = 5 and x[2] = 7 \n" + "group by d \n" + "having a.c < 5 \n" + "order by x.a.a.a.a.a");
String expected = "SELECT `a`[4]['c']\n" + "FROM `x`.`y`.`z`\n" + "WHERE `a`.`c`['b'] = 5 AND `x`[2] = 7\n" + "GROUP BY `d`\n" + "HAVING `a`.`c` < 5\n" + "ORDER BY `x`.`a`['a']['a']['a']['a']";
SqlNode rewritten = node.accept(new CompoundIdentifierConverter(false));
String rewrittenQuery = rewritten.toString();
DrillAssert.assertMultiLineStringEquals(expected, rewrittenQuery);
}
Aggregations