@Test public void selectNumberAndDateShouldReturnProductOfThemAsQueryVisitingResult() { Type result = visit("SELECT age, birthday FROM test"); Assert.assertTrue(result instanceof Product ); Assert.assertTrue(result.isCompatible(new Product(Arrays.asList(INTEGER, DATE)))); }
private <Node1 extends ParseTree, Node2 extends ParseTree> List<ParseTree> asList(Node1 first, List<Node2> rest) { List<ParseTree> result = new ArrayList<>(singleton(first)); result.addAll(rest); return result; }
AntlrSqlParseTreeVisitor extends OpenDistroSqlParserBaseVisitor<T> { private <Node1 extends ParseTree, Node2 extends ParseTree> List<ParseTree> asList(Node1 first, List<Node2> rest) { List<ParseTree> result = new ArrayList<>(singleton(first)); result.addAll(rest); return result; } }
AntlrSqlParseTreeVisitor extends OpenDistroSqlParserBaseVisitor<T> { private <Node1 extends ParseTree, Node2 extends ParseTree> List<ParseTree> asList(Node1 first, List<Node2> rest) { List<ParseTree> result = new ArrayList<>(singleton(first)); result.addAll(rest); return result; } AntlrSqlParseTreeVisitor(GenericSqlParseTreeVisitor<T> visitor); }
AntlrSqlParseTreeVisitor extends OpenDistroSqlParserBaseVisitor<T> { private <Node1 extends ParseTree, Node2 extends ParseTree> List<ParseTree> asList(Node1 first, List<Node2> rest) { List<ParseTree> result = new ArrayList<>(singleton(first)); result.addAll(rest); return result; } AntlrSqlParseTreeVisitor(GenericSqlParseTreeVisitor<T> visitor); @Override T visitRoot(RootContext ctx); @Override T visitUnionSelect(UnionSelectContext ctx); @Override T visitMinusSelect(MinusSelectContext ctx); @Override T visitInPredicate(InPredicateContext ctx); @Override T visitTableSources(TableSourcesContext ctx); @Override T visitTableSourceBase(TableSourceBaseContext ctx); @Override T visitInnerJoin(InnerJoinContext ctx); @Override T visitOuterJoin(OuterJoinContext ctx); @Override T visitQuerySpecification(QuerySpecificationContext ctx); @Override T visitSubqueryTableItem(SubqueryTableItemContext ctx); @Override T visitAtomTableItem(AtomTableItemContext ctx); @Override T visitSimpleTableName(SimpleTableNameContext ctx); @Override T visitTableNamePattern(TableNamePatternContext ctx); @Override T visitTableAndTypeName(TableAndTypeNameContext ctx); @Override T visitFullColumnName(FullColumnNameContext ctx); @Override T visitUdfFunctionCall(UdfFunctionCallContext ctx); @Override T visitScalarFunctionCall(ScalarFunctionCallContext ctx); @Override T visitMathOperator(MathOperatorContext ctx); @Override T visitRegexpPredicate(RegexpPredicateContext ctx); @Override T visitSelectElements(SelectElementsContext ctx); @Override T visitSelectStarElement(OpenDistroSqlParser.SelectStarElementContext ctx); @Override T visitSelectColumnElement(SelectColumnElementContext ctx); @Override T visitSelectFunctionElement(SelectFunctionElementContext ctx); @Override T visitSelectExpressionElement(SelectExpressionElementContext ctx); @Override T visitAggregateWindowedFunction(AggregateWindowedFunctionContext ctx); @Override T visitFunctionNameBase(FunctionNameBaseContext ctx); @Override T visitBinaryComparisonPredicate(BinaryComparisonPredicateContext ctx); @Override T visitIsExpression(IsExpressionContext ctx); @Override T visitConvertedDataType(OpenDistroSqlParser.ConvertedDataTypeContext ctx); @Override T visitComparisonOperator(ComparisonOperatorContext ctx); @Override T visitConstant(ConstantContext ctx); @Override T visitStringLiteral(StringLiteralContext ctx); @Override T visitDecimalLiteral(DecimalLiteralContext ctx); @Override T visitBooleanLiteral(BooleanLiteralContext ctx); }
AntlrSqlParseTreeVisitor extends OpenDistroSqlParserBaseVisitor<T> { private <Node1 extends ParseTree, Node2 extends ParseTree> List<ParseTree> asList(Node1 first, List<Node2> rest) { List<ParseTree> result = new ArrayList<>(singleton(first)); result.addAll(rest); return result; } AntlrSqlParseTreeVisitor(GenericSqlParseTreeVisitor<T> visitor); @Override T visitRoot(RootContext ctx); @Override T visitUnionSelect(UnionSelectContext ctx); @Override T visitMinusSelect(MinusSelectContext ctx); @Override T visitInPredicate(InPredicateContext ctx); @Override T visitTableSources(TableSourcesContext ctx); @Override T visitTableSourceBase(TableSourceBaseContext ctx); @Override T visitInnerJoin(InnerJoinContext ctx); @Override T visitOuterJoin(OuterJoinContext ctx); @Override T visitQuerySpecification(QuerySpecificationContext ctx); @Override T visitSubqueryTableItem(SubqueryTableItemContext ctx); @Override T visitAtomTableItem(AtomTableItemContext ctx); @Override T visitSimpleTableName(SimpleTableNameContext ctx); @Override T visitTableNamePattern(TableNamePatternContext ctx); @Override T visitTableAndTypeName(TableAndTypeNameContext ctx); @Override T visitFullColumnName(FullColumnNameContext ctx); @Override T visitUdfFunctionCall(UdfFunctionCallContext ctx); @Override T visitScalarFunctionCall(ScalarFunctionCallContext ctx); @Override T visitMathOperator(MathOperatorContext ctx); @Override T visitRegexpPredicate(RegexpPredicateContext ctx); @Override T visitSelectElements(SelectElementsContext ctx); @Override T visitSelectStarElement(OpenDistroSqlParser.SelectStarElementContext ctx); @Override T visitSelectColumnElement(SelectColumnElementContext ctx); @Override T visitSelectFunctionElement(SelectFunctionElementContext ctx); @Override T visitSelectExpressionElement(SelectExpressionElementContext ctx); @Override T visitAggregateWindowedFunction(AggregateWindowedFunctionContext ctx); @Override T visitFunctionNameBase(FunctionNameBaseContext ctx); @Override T visitBinaryComparisonPredicate(BinaryComparisonPredicateContext ctx); @Override T visitIsExpression(IsExpressionContext ctx); @Override T visitConvertedDataType(OpenDistroSqlParser.ConvertedDataTypeContext ctx); @Override T visitComparisonOperator(ComparisonOperatorContext ctx); @Override T visitConstant(ConstantContext ctx); @Override T visitStringLiteral(StringLiteralContext ctx); @Override T visitDecimalLiteral(DecimalLiteralContext ctx); @Override T visitBooleanLiteral(BooleanLiteralContext ctx);  }