@Override public ColumnPlanNode visitCompoundExpr(CompoundExpr compoundExpr) { NodeMatcher nodeMatcher = new NodeMatcher(formTree); Collection<NodeMatch> nodeMatches = nodeMatcher.resolveCompoundExpr(compoundExpr); return plan(nodeMatches); } });
@Override public Slot<ColumnView> visitCompoundExpr(CompoundExpr compoundExpr) { return addColumn(resolver.resolveCompoundExpr(compoundExpr)); }
@Override public Slot<ColumnView> visitFunctionCall(final FunctionCallNode call) { if(call.getFunction() instanceof ColumnFunction) { if(call.getArguments().isEmpty()) { return createNullaryFunctionCall(call); } else { return createFunctionCall(call); } } else if(call.getFunction() instanceof BoundingBoxFunction) { FormulaNode geometry = call.getArgument(0); Collection<NodeMatch> nodes; if(geometry instanceof SymbolNode) { nodes = resolver.resolveSymbol(((SymbolNode) geometry)); } else if(geometry instanceof CompoundExpr) { nodes = resolver.resolveCompoundExpr((CompoundExpr) geometry); } else { throw new QuerySyntaxException("Function " + call.getFunction().getId() + " can only be applied" + " to an argument of type GeoArea."); } return addColumn(nodes.stream().map(n -> n.withComponent(call.getFunction().getId())).collect(Collectors.toList())); } else { throw new UnsupportedOperationException("TODO: " + call.getFunction().getId()); } }
matches = nodeMatcher.resolveSymbol((SymbolNode) formulaNode); } else if (formulaNode instanceof CompoundExpr) { matches = nodeMatcher.resolveCompoundExpr((CompoundExpr) formulaNode); } else { throw new IllegalArgumentException();
private Collection<String> resolve(String exprString) { FormTree tree = tree(); symbolTable = new NodeMatcher(tree); FormulaNode expr = FormulaParser.parse(exprString); Collection<NodeMatch> matches; if(expr instanceof SymbolNode) { matches = symbolTable.resolveSymbol((SymbolNode) expr); } else if(expr instanceof CompoundExpr) { matches = symbolTable.resolveCompoundExpr((CompoundExpr) expr); } else { throw new IllegalArgumentException(exprString); } // Create a string that we can match against easily List<String> strings = Lists.newArrayList(); for (NodeMatch match : matches) { strings.add(match.toDebugString()); } System.out.println("Resolved " + exprString + " => " + strings); return strings; }