/** Parse a special literal keyword */ final public SqlLiteral SpecialLiteral() throws ParseException { if (jj_2_327(2)) { jj_consume_token(TRUE); {if (true) return SqlLiteral.createBoolean(true, getPos());} } else if (jj_2_328(2)) { jj_consume_token(FALSE); {if (true) return SqlLiteral.createBoolean(false, getPos());} } else if (jj_2_329(2)) { jj_consume_token(UNKNOWN); {if (true) return SqlLiteral.createUnknown(getPos());} } else if (jj_2_330(2)) { jj_consume_token(NULL); {if (true) return SqlLiteral.createNull(getPos());} } else { jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); }
/** Parse a special literal keyword */ final public SqlLiteral SpecialLiteral() throws ParseException { if (jj_2_327(2)) { jj_consume_token(TRUE); {if (true) return SqlLiteral.createBoolean(true, getPos());} } else if (jj_2_328(2)) { jj_consume_token(FALSE); {if (true) return SqlLiteral.createBoolean(false, getPos());} } else if (jj_2_329(2)) { jj_consume_token(UNKNOWN); {if (true) return SqlLiteral.createUnknown(getPos());} } else if (jj_2_330(2)) { jj_consume_token(NULL); {if (true) return SqlLiteral.createNull(getPos());} } else { jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); }
/** Parse a special literal keyword */ final public SqlLiteral SpecialLiteral() throws ParseException { if (jj_2_332(2)) { jj_consume_token(TRUE); {if ("" != null) return SqlLiteral.createBoolean(true, getPos());} } else if (jj_2_333(2)) { jj_consume_token(FALSE); {if ("" != null) return SqlLiteral.createBoolean(false, getPos());} } else if (jj_2_334(2)) { jj_consume_token(UNKNOWN); {if ("" != null) return SqlLiteral.createUnknown(getPos());} } else if (jj_2_335(2)) { jj_consume_token(NULL); {if ("" != null) return SqlLiteral.createNull(getPos());} } else { jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); }
/** * Creates a call to the switched form of the case operator, viz: * * <blockquote><code>CASE value<br> * WHEN whenList[0] THEN thenList[0]<br> * WHEN whenList[1] THEN thenList[1]<br> * ...<br> * ELSE elseClause<br> * END</code></blockquote> */ public static SqlCase createSwitched(SqlParserPos pos, SqlNode value, SqlNodeList whenList, SqlNodeList thenList, SqlNode elseClause) { if (null != value) { List<SqlNode> list = whenList.getList(); for (int i = 0; i < list.size(); i++) { SqlNode e = list.get(i); final SqlCall call; if (e instanceof SqlNodeList) { call = SqlStdOperatorTable.IN.createCall(pos, value, e); } else { call = SqlStdOperatorTable.EQUALS.createCall(pos, value, e); } list.set(i, call); } } if (null == elseClause) { elseClause = SqlLiteral.createNull(pos); } return new SqlCase(pos, null, whenList, thenList, elseClause); }
/** * Creates a call to the switched form of the case operator, viz: * * <blockquote><code>CASE value<br> * WHEN whenList[0] THEN thenList[0]<br> * WHEN whenList[1] THEN thenList[1]<br> * ...<br> * ELSE elseClause<br> * END</code></blockquote> */ public static SqlCase createSwitched(SqlParserPos pos, SqlNode value, SqlNodeList whenList, SqlNodeList thenList, SqlNode elseClause) { if (null != value) { List<SqlNode> list = whenList.getList(); for (int i = 0; i < list.size(); i++) { SqlNode e = list.get(i); final SqlCall call; if (e instanceof SqlNodeList) { call = SqlStdOperatorTable.IN.createCall(pos, value, e); } else { call = SqlStdOperatorTable.EQUALS.createCall(pos, value, e); } list.set(i, call); } } if (null == elseClause) { elseClause = SqlLiteral.createNull(pos); } return new SqlCase(pos, null, whenList, thenList, elseClause); }
public SqlNode rewriteCall(SqlValidator validator, SqlCall call) { List<SqlNode> operands = call.getOperandList(); SqlParserPos pos = call.getParserPosition(); checkOperandCount( validator, getOperandTypeChecker(), call); assert operands.size() == 2; SqlNodeList whenList = new SqlNodeList(pos); SqlNodeList thenList = new SqlNodeList(pos); whenList.add(operands.get(1)); thenList.add(SqlLiteral.createNull(SqlParserPos.ZERO)); return SqlCase.createSwitched(pos, operands.get(0), whenList, thenList, SqlNode.clone(operands.get(0))); } }
public SqlNode rewriteCall(SqlValidator validator, SqlCall call) { List<SqlNode> operands = call.getOperandList(); SqlParserPos pos = call.getParserPosition(); checkOperandCount( validator, getOperandTypeChecker(), call); assert operands.size() == 2; SqlNodeList whenList = new SqlNodeList(pos); SqlNodeList thenList = new SqlNodeList(pos); whenList.add(operands.get(1)); thenList.add(SqlLiteral.createNull(SqlParserPos.ZERO)); return SqlCase.createSwitched(pos, operands.get(0), whenList, thenList, SqlNode.clone(operands.get(0))); } }
@Override public SqlNode rewriteSingleValueExpr(SqlNode aggCall) { final SqlNode operand = ((SqlBasicCall) aggCall).operand(0); final SqlLiteral nullLiteral = SqlLiteral.createNull(SqlParserPos.ZERO); final SqlNode unionOperand = new SqlSelect(SqlParserPos.ZERO, SqlNodeList.EMPTY, SqlNodeList.of(nullLiteral), null, null, null, null, SqlNodeList.EMPTY, null, null, null); // For MySQL, generate // CASE COUNT(*) // WHEN 0 THEN NULL // WHEN 1 THEN <result> // ELSE (SELECT NULL UNION ALL SELECT NULL) // END final SqlNode caseExpr = new SqlCase(SqlParserPos.ZERO, SqlStdOperatorTable.COUNT.createCall(SqlParserPos.ZERO, operand), SqlNodeList.of( SqlLiteral.createExactNumeric("0", SqlParserPos.ZERO), SqlLiteral.createExactNumeric("1", SqlParserPos.ZERO)), SqlNodeList.of( nullLiteral, operand), SqlStdOperatorTable.SCALAR_QUERY.createCall(SqlParserPos.ZERO, SqlStdOperatorTable.UNION_ALL .createCall(SqlParserPos.ZERO, unionOperand, unionOperand))); LOGGER.debug("SINGLE_VALUE rewritten into [{}]", caseExpr); return caseExpr; }
@Override public SqlNode rewriteSingleValueExpr(SqlNode aggCall) { final SqlNode operand = ((SqlBasicCall) aggCall).operand(0); final SqlLiteral nullLiteral = SqlLiteral.createNull(SqlParserPos.ZERO); final SqlNode unionOperand = new SqlSelect(SqlParserPos.ZERO, SqlNodeList.EMPTY, SqlNodeList.of(nullLiteral), null, null, null, null, SqlNodeList.EMPTY, null, null, null); // For MySQL, generate // CASE COUNT(*) // WHEN 0 THEN NULL // WHEN 1 THEN <result> // ELSE (SELECT NULL UNION ALL SELECT NULL) // END final SqlNode caseExpr = new SqlCase(SqlParserPos.ZERO, SqlStdOperatorTable.COUNT.createCall(SqlParserPos.ZERO, operand), SqlNodeList.of( SqlLiteral.createExactNumeric("0", SqlParserPos.ZERO), SqlLiteral.createExactNumeric("1", SqlParserPos.ZERO) ), SqlNodeList.of( nullLiteral, operand ), SqlStdOperatorTable.SCALAR_QUERY.createCall(SqlParserPos.ZERO, SqlStdOperatorTable.UNION_ALL .createCall(SqlParserPos.ZERO, unionOperand, unionOperand))); LOGGER.debug("SINGLE_VALUE rewritten into [{}]", caseExpr); return caseExpr; }
@Override public SqlNode rewriteSingleValueExpr(SqlNode aggCall) { final SqlNode operand = ((SqlBasicCall) aggCall).operand(0); final SqlLiteral nullLiteral = SqlLiteral.createNull(SqlParserPos.ZERO); final SqlNode unionOperand = SqlStdOperatorTable.VALUES.createCall(SqlParserPos.ZERO, SqlLiteral.createApproxNumeric("0", SqlParserPos.ZERO)); // For hsqldb, generate // CASE COUNT(*) // WHEN 0 THEN NULL // WHEN 1 THEN MIN(<result>) // ELSE (VALUES 1 UNION ALL VALUES 1) // END final SqlNode caseExpr = new SqlCase(SqlParserPos.ZERO, SqlStdOperatorTable.COUNT.createCall(SqlParserPos.ZERO, operand), SqlNodeList.of( SqlLiteral.createExactNumeric("0", SqlParserPos.ZERO), SqlLiteral.createExactNumeric("1", SqlParserPos.ZERO) ), SqlNodeList.of( nullLiteral, SqlStdOperatorTable.MIN.createCall(SqlParserPos.ZERO, operand) ), SqlStdOperatorTable.SCALAR_QUERY.createCall(SqlParserPos.ZERO, SqlStdOperatorTable.UNION_ALL .createCall(SqlParserPos.ZERO, unionOperand, unionOperand))); LOGGER.debug("SINGLE_VALUE rewritten into [{}]", caseExpr); return caseExpr; }
@Override public SqlNode rewriteSingleValueExpr(SqlNode aggCall) { final SqlNode operand = ((SqlBasicCall) aggCall).operand(0); final SqlLiteral nullLiteral = SqlLiteral.createNull(SqlParserPos.ZERO); final SqlNode unionOperand = SqlStdOperatorTable.VALUES.createCall(SqlParserPos.ZERO, SqlLiteral.createApproxNumeric("0", SqlParserPos.ZERO)); // For hsqldb, generate // CASE COUNT(*) // WHEN 0 THEN NULL // WHEN 1 THEN MIN(<result>) // ELSE (VALUES 1 UNION ALL VALUES 1) // END final SqlNode caseExpr = new SqlCase(SqlParserPos.ZERO, SqlStdOperatorTable.COUNT.createCall(SqlParserPos.ZERO, operand), SqlNodeList.of( SqlLiteral.createExactNumeric("0", SqlParserPos.ZERO), SqlLiteral.createExactNumeric("1", SqlParserPos.ZERO)), SqlNodeList.of( nullLiteral, SqlStdOperatorTable.MIN.createCall(SqlParserPos.ZERO, operand)), SqlStdOperatorTable.SCALAR_QUERY.createCall(SqlParserPos.ZERO, SqlStdOperatorTable.UNION_ALL .createCall(SqlParserPos.ZERO, unionOperand, unionOperand))); LOGGER.debug("SINGLE_VALUE rewritten into [{}]", caseExpr); return caseExpr; }
/** Parse a special literal keyword */ final public SqlLiteral SpecialLiteral() throws ParseException { if (jj_2_324(2)) { jj_consume_token(TRUE); {if (true) return SqlLiteral.createBoolean(true, getPos());} } else if (jj_2_325(2)) { jj_consume_token(FALSE); {if (true) return SqlLiteral.createBoolean(false, getPos());} } else if (jj_2_326(2)) { jj_consume_token(UNKNOWN); {if (true) return SqlLiteral.createUnknown(getPos());} } else if (jj_2_327(2)) { jj_consume_token(NULL); {if (true) return SqlLiteral.createNull(getPos());} } else { jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); }
/** Parse a special literal keyword */ final public SqlLiteral SpecialLiteral() throws ParseException { if (jj_2_267(2)) { jj_consume_token(TRUE); {if (true) return SqlLiteral.createBoolean(true, getPos());} } else if (jj_2_268(2)) { jj_consume_token(FALSE); {if (true) return SqlLiteral.createBoolean(false, getPos());} } else if (jj_2_269(2)) { jj_consume_token(UNKNOWN); {if (true) return SqlLiteral.createUnknown(getPos());} } else if (jj_2_270(2)) { jj_consume_token(NULL); {if (true) return SqlLiteral.createNull(getPos());} } else { jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); }
/** Parse a special literal keyword */ final public SqlLiteral SpecialLiteral() throws ParseException { if (jj_2_311(2)) { jj_consume_token(TRUE); {if (true) return SqlLiteral.createBoolean(true, getPos());} } else if (jj_2_312(2)) { jj_consume_token(FALSE); {if (true) return SqlLiteral.createBoolean(false, getPos());} } else if (jj_2_313(2)) { jj_consume_token(UNKNOWN); {if (true) return SqlLiteral.createUnknown(getPos());} } else if (jj_2_314(2)) { jj_consume_token(NULL); {if (true) return SqlLiteral.createNull(getPos());} } else { jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); }
/** Parse a special literal keyword */ final public SqlLiteral SpecialLiteral() throws ParseException { if (jj_2_461(2)) { jj_consume_token(TRUE); {if (true) return SqlLiteral.createBoolean(true, getPos());} } else if (jj_2_462(2)) { jj_consume_token(FALSE); {if (true) return SqlLiteral.createBoolean(false, getPos());} } else if (jj_2_463(2)) { jj_consume_token(UNKNOWN); {if (true) return SqlLiteral.createUnknown(getPos());} } else if (jj_2_464(2)) { jj_consume_token(NULL); {if (true) return SqlLiteral.createNull(getPos());} } else { jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); }
/** Parse a special literal keyword */ final public SqlLiteral SpecialLiteral() throws ParseException { if (jj_2_365(2)) { jj_consume_token(TRUE); {if (true) return SqlLiteral.createBoolean(true, getPos());} } else if (jj_2_366(2)) { jj_consume_token(FALSE); {if (true) return SqlLiteral.createBoolean(false, getPos());} } else if (jj_2_367(2)) { jj_consume_token(UNKNOWN); {if (true) return SqlLiteral.createUnknown(getPos());} } else if (jj_2_368(2)) { jj_consume_token(NULL); {if (true) return SqlLiteral.createNull(getPos());} } else { jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); }
/** Parse a special literal keyword */ final public SqlLiteral SpecialLiteral() throws ParseException { if (jj_2_371(2)) { jj_consume_token(TRUE); {if (true) return SqlLiteral.createBoolean(true, getPos());} } else if (jj_2_372(2)) { jj_consume_token(FALSE); {if (true) return SqlLiteral.createBoolean(false, getPos());} } else if (jj_2_373(2)) { jj_consume_token(UNKNOWN); {if (true) return SqlLiteral.createUnknown(getPos());} } else if (jj_2_374(2)) { jj_consume_token(NULL); {if (true) return SqlLiteral.createNull(getPos());} } else { jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); }
/** Parse a special literal keyword */ final public SqlLiteral SpecialLiteral() throws ParseException { if (jj_2_335(2)) { jj_consume_token(TRUE); {if (true) return SqlLiteral.createBoolean(true, getPos());} } else if (jj_2_336(2)) { jj_consume_token(FALSE); {if (true) return SqlLiteral.createBoolean(false, getPos());} } else if (jj_2_337(2)) { jj_consume_token(UNKNOWN); {if (true) return SqlLiteral.createUnknown(getPos());} } else if (jj_2_338(2)) { jj_consume_token(NULL); {if (true) return SqlLiteral.createNull(getPos());} } else { jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); }
/** Parse a special literal keyword */ final public SqlLiteral SpecialLiteral() throws ParseException { if (jj_2_330(2)) { jj_consume_token(TRUE); {if (true) return SqlLiteral.createBoolean(true, getPos());} } else if (jj_2_331(2)) { jj_consume_token(FALSE); {if (true) return SqlLiteral.createBoolean(false, getPos());} } else if (jj_2_332(2)) { jj_consume_token(UNKNOWN); {if (true) return SqlLiteral.createUnknown(getPos());} } else if (jj_2_333(2)) { jj_consume_token(NULL); {if (true) return SqlLiteral.createNull(getPos());} } else { jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); }
/** Parse a special literal keyword */ final public SqlLiteral SpecialLiteral() throws ParseException { if (jj_2_267(2)) { jj_consume_token(TRUE); {if (true) return SqlLiteral.createBoolean(true, getPos());} } else if (jj_2_268(2)) { jj_consume_token(FALSE); {if (true) return SqlLiteral.createBoolean(false, getPos());} } else if (jj_2_269(2)) { jj_consume_token(UNKNOWN); {if (true) return SqlLiteral.createUnknown(getPos());} } else if (jj_2_270(2)) { jj_consume_token(NULL); {if (true) return SqlLiteral.createNull(getPos());} } else { jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); }