public CaseExpression(Expression conditionExpr, List<Expression> whenExprs, List<Expression> thenExprs, Expression elseExpr) { this.conditionExpr = conditionExpr; this.whenExprs.addAll(whenExprs); this.thenExprs.addAll(thenExprs); // If no when expression matches the case expr, we return null this.elseExpr = elseExpr == null ? new LiteralExpr(NullLiteral.INSTANCE) : elseExpr; }
private static List<Expression> addArgs(Object... args) { List<Expression> argExprs = new ArrayList<>(); for (Object arg : args) { if (arg instanceof Integer) { argExprs.add(new LiteralExpr(new IntegerLiteral((Integer) arg))); } else if (arg instanceof String) { argExprs.add(new LiteralExpr(new StringLiteral((String) arg))); } else if (arg instanceof Expression) { argExprs.add((Expression) arg); } } return argExprs; }
private FieldBinding generateFieldBinding(String fieldName, Expression fieldValueExpr, Set<String> outFieldNames, SourceLocation sourceLoc) throws CompilationException { if (!outFieldNames.add(fieldName)) { throw new CompilationException(ErrorCode.DUPLICATE_FIELD_NAME, sourceLoc, fieldName); } return new FieldBinding(new LiteralExpr(new StringLiteral(fieldName)), fieldValueExpr); }
private Expression resolveAsFieldAccess(VariableExpr var, String fieldName, SourceLocation sourceLoc) { List<Expression> argList = new ArrayList<>(2); argList.add(var); argList.add(new LiteralExpr(new StringLiteral(fieldName))); CallExpr callExpr = new CallExpr(new FunctionSignature(BuiltinFunctions.FIELD_ACCESS_BY_NAME), argList); callExpr.setSourceLocation(sourceLoc); return callExpr; }
private Expression resolveAsDataset(String dataverseName, String datasetName, SourceLocation sourceLoc) throws CompilationException { if (!datasetExists(dataverseName, datasetName, sourceLoc)) { throwUnresolvableError(dataverseName, datasetName, sourceLoc); } String fullyQualifiedName = dataverseName == null ? datasetName : dataverseName + "." + datasetName; List<Expression> argList = new ArrayList<>(1); argList.add(new LiteralExpr(new StringLiteral(fullyQualifiedName))); CallExpr callExpr = new CallExpr(new FunctionSignature(BuiltinFunctions.DATASET), argList); callExpr.setSourceLocation(sourceLoc); return callExpr; }
protected AbstractFunctionCallExpression createRecordConstructor(List<Pair<Expression, Identifier>> fieldList, Mutable<ILogicalOperator> inputOp, SourceLocation sourceLoc) throws CompilationException { List<Mutable<ILogicalExpression>> args = new ArrayList<>(); for (Pair<Expression, Identifier> field : fieldList) { ILogicalExpression fieldNameExpr = langExprToAlgExpression(new LiteralExpr(new StringLiteral(field.second.getValue())), inputOp).first; args.add(new MutableObject<>(fieldNameExpr)); ILogicalExpression fieldExpr = langExprToAlgExpression(field.first, inputOp).first; args.add(new MutableObject<>(fieldExpr)); } ScalarFunctionCallExpression recordConstr = new ScalarFunctionCallExpression( FunctionUtil.getFunctionInfo(BuiltinFunctions.OPEN_RECORD_CONSTRUCTOR), args); recordConstr.setSourceLocation(sourceLoc); return recordConstr; }
final public Expression Literal() throws ParseException, ParseException { LiteralExpr lit = new LiteralExpr(); String str = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
@Override public Void visit(DeleteStatement deleteStmt, Void visitArg) { List<Expression> arguments = new ArrayList<>(); Identifier dataverseName = deleteStmt.getDataverseName(); Identifier datasetName = deleteStmt.getDatasetName(); String arg = dataverseName == null ? datasetName.getValue() : dataverseName.getValue() + "." + datasetName.getValue(); LiteralExpr argumentLiteral = new LiteralExpr(new StringLiteral(arg)); arguments.add(argumentLiteral); CallExpr callExpression = new CallExpr(new FunctionSignature(BuiltinFunctions.DATASET), arguments); List<Clause> clauseList = new ArrayList<>(); VariableExpr var = deleteStmt.getVariableExpr(); Clause forClause = new ForClause(var, callExpression); clauseList.add(forClause); Clause whereClause = null; Expression condition = deleteStmt.getCondition(); if (condition != null) { whereClause = new WhereClause(condition); clauseList.add(whereClause); } VariableExpr returnExpr = new VariableExpr(var.getVar()); returnExpr.setIsNewVar(false); FLWOGRExpression flowgr = new FLWOGRExpression(clauseList, returnExpr); Query query = new Query(false); query.setBody(flowgr); deleteStmt.setQuery(query); return null; }
LiteralExpr litExpr = new LiteralExpr(TrueLiteral.INSTANCE); conditionExpr = addSourceLocation(litExpr, startToken);
final public Expression Literal() throws ParseException, ParseException { LiteralExpr lit = new LiteralExpr(); String str = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
LiteralExpr ds = new LiteralExpr(); ds.setValue( new StringLiteral(name) ); nameArg = ds;
LiteralExpr ds = new LiteralExpr(); ds.setValue( new StringLiteral(name) ); nameArg = ds;
private CaseExpression normalizeCaseExpr(CaseExpression caseExpr) throws CompilationException { LiteralExpr trueLiteral = new LiteralExpr(TrueLiteral.INSTANCE); trueLiteral.setSourceLocation(caseExpr.getSourceLocation()); Expression conditionExpr = caseExpr.getConditionExpr(); if (trueLiteral.equals(conditionExpr)) { return caseExpr; } List<Expression> normalizedWhenExprs = new ArrayList<>(); for (Expression expr : caseExpr.getWhenExprs()) { OperatorExpr operatorExpr = new OperatorExpr(); operatorExpr.addOperand((Expression) SqlppRewriteUtil.deepCopy(expr)); operatorExpr.addOperand(caseExpr.getConditionExpr()); operatorExpr.addOperator(OperatorType.EQ); operatorExpr.setSourceLocation(expr.getSourceLocation()); normalizedWhenExprs.add(operatorExpr); } CaseExpression newCaseExpr = new CaseExpression(trueLiteral, normalizedWhenExprs, caseExpr.getThenExprs(), caseExpr.getElseExpr()); newCaseExpr.setSourceLocation(caseExpr.getSourceLocation()); return newCaseExpr; }
{if (true) throw new SqlppParseException(getSourceLocation(token), "The parameter * can only be used in COUNT().");} argList.add(new LiteralExpr(new LongIntegerLiteral(1L))); } else { argList.add(tmp);
final public Expression Literal() throws ParseException, ParseException { LiteralExpr lit = new LiteralExpr(); String str = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
BuiltinFunctions.LEAD_IMPL.equals(fi) ? WindowExpression.FrameBoundaryKind.BOUNDED_FOLLOWING : WindowExpression.FrameBoundaryKind.BOUNDED_PRECEDING; winFrameStartExpr = argCount > 1 ? fargs.get(1) : new LiteralExpr(new IntegerLiteral(1)); winFrameEndExpr = (Expression) SqlppRewriteUtil.deepCopy(winFrameStartExpr); opExpr.addOperand(fargs.get(1)); opExpr.addOperator(OperatorType.MINUS); opExpr.addOperand(new LiteralExpr(new IntegerLiteral(1))); opExpr.setSourceLocation(sourceLoc); winFrameOffsetExpr = opExpr;
String arg = dataverseName == null ? datasetName.getValue() : dataverseName.getValue() + "." + datasetName.getValue(); LiteralExpr argumentLiteral = new LiteralExpr(new StringLiteral(arg)); arguments.add(argumentLiteral); CallExpr callExpression = new CallExpr(new FunctionSignature(BuiltinFunctions.DATASET), arguments);