if (call.getFunctionQuantifier() != null && call.getFunctionQuantifier().getValue() == SqlSelectKeyword.DISTINCT) { final SqlParserPos pos = call.getParserPosition(); throw SqlUtil.newContextException(pos, Static.RESOURCE.functionQuantifierNotAllowed(call.toString()));
private boolean isCountDistinct(SqlCall call) { return call.getKind() == SqlKind.COUNT && call.getFunctionQuantifier() != null && call.getFunctionQuantifier().getValue() == SqlSelectKeyword.DISTINCT; }
private boolean isCountDistinct(SqlCall call) { return call.getKind() == SqlKind.COUNT && call.getFunctionQuantifier() != null && call.getFunctionQuantifier().getValue() == SqlSelectKeyword.DISTINCT; }
@Override public SqlNode clone(SqlParserPos pos) { final List<SqlNode> operandList = getOperandList(); return getOperator().createCall(getFunctionQuantifier(), pos, operandList.toArray(new SqlNode[0])); }
@Override public SqlNode clone(SqlParserPos pos) { final List<SqlNode> operandList = getOperandList(); return getOperator().createCall(getFunctionQuantifier(), pos, operandList.toArray(new SqlNode[0])); }
/** * Throws a validation error if a DISTINCT or ALL quantifier is present but * not allowed. */ protected void validateQuantifier(SqlValidator validator, SqlCall call) { if ((null != call.getFunctionQuantifier()) && !isQuantifierAllowed()) { throw validator.newValidationError(call.getFunctionQuantifier(), RESOURCE.functionQuantifierNotAllowed(call.getOperator().getName())); } }
/** * Throws a validation error if a DISTINCT or ALL quantifier is present but * not allowed. */ protected void validateQuantifier(SqlValidator validator, SqlCall call) { if ((null != call.getFunctionQuantifier()) && !isQuantifierAllowed()) { throw validator.newValidationError(call.getFunctionQuantifier(), RESOURCE.functionQuantifierNotAllowed(call.getOperator().getName())); } }
public SqlNode result() { if (update || alwaysCopy) { return call.getOperator().createCall( call.getFunctionQuantifier(), call.getParserPosition(), clonedOperands); } else { return call; } }
@Override public SqlNode result() { if (update) { return call.getOperator().createCall( call.getFunctionQuantifier(), call.getParserPosition(), clonedOperands); } else { return call; } }
/** * Copies a {@link SqlCall}, replacing the time unit operand with the given * literal. * * @param call Call * @param literal Literal to replace time unit with * @param pos Parser position * @return Modified call */ public static SqlCall replaceTimeUnitOperand(SqlCall call, String literal, SqlParserPos pos) { SqlLiteral literalNode = SqlLiteral.createCharString(literal, null, pos); return call.getOperator().createCall(call.getFunctionQuantifier(), pos, call.getOperandList().get(0), literalNode); }
public SqlNode result() { if (update || alwaysCopy) { return call.getOperator().createCall( call.getFunctionQuantifier(), call.getParserPosition(), clonedOperands); } else { return call; } }
@Override public SqlNode result() { if (update) { return call.getOperator().createCall( call.getFunctionQuantifier(), call.getParserPosition(), clonedOperands); } else { return call; } }
/** * Copies a {@link SqlCall}, replacing the time unit operand with the given * literal. * * @param call Call * @param literal Literal to replace time unit with * @param pos Parser position * @return Modified call */ public static SqlCall replaceTimeUnitOperand(SqlCall call, String literal, SqlParserPos pos) { SqlLiteral literalNode = SqlLiteral.createCharString(literal, null, pos); return call.getOperator().createCall(call.getFunctionQuantifier(), pos, call.getOperandList().get(0), literalNode); }
private boolean isSimpleCount(SqlCall call) { if (call.getOperator().isName("COUNT") && call.operandCount() == 1) { final SqlNode parm = call.operand(0); if ((parm instanceof SqlIdentifier || parm instanceof SqlNumericLiteral) // && call.getFunctionQuantifier() == null) { return true; } } return false; }
public SqlNode rewriteCall(SqlValidator validator, SqlCall call) { validateQuantifier(validator, call); // check DISTINCT/ALL List<SqlNode> operands = call.getOperandList(); if (operands.size() == 1) { // No CASE needed return operands.get(0); } SqlParserPos pos = call.getParserPosition(); SqlNodeList whenList = new SqlNodeList(pos); SqlNodeList thenList = new SqlNodeList(pos); // todo: optimize when know operand is not null. for (SqlNode operand : Util.skipLast(operands)) { whenList.add( SqlStdOperatorTable.IS_NOT_NULL.createCall(pos, operand)); thenList.add(SqlNode.clone(operand)); } SqlNode elseExpr = Util.last(operands); assert call.getFunctionQuantifier() == null; return SqlCase.createSwitched(pos, null, whenList, thenList, elseExpr); } }
final RelDataType type = validator.deriveType(bb.scope, call); boolean distinct = false; SqlLiteral quantifier = call.getFunctionQuantifier(); if ((null != quantifier) && (quantifier.getValue() == SqlSelectKeyword.DISTINCT)) {
public SqlNode rewriteCall(SqlValidator validator, SqlCall call) { validateQuantifier(validator, call); // check DISTINCT/ALL List<SqlNode> operands = call.getOperandList(); if (operands.size() == 1) { // No CASE needed return operands.get(0); } SqlParserPos pos = call.getParserPosition(); SqlNodeList whenList = new SqlNodeList(pos); SqlNodeList thenList = new SqlNodeList(pos); // todo: optimize when know operand is not null. for (SqlNode operand : Util.skipLast(operands)) { whenList.add( SqlStdOperatorTable.IS_NOT_NULL.createCall(pos, operand)); thenList.add(SqlNode.clone(operand)); } SqlNode elseExpr = Util.last(operands); assert call.getFunctionQuantifier() == null; return SqlCase.createSwitched(pos, null, whenList, thenList, elseExpr); } }
if (aggCall.getFunctionQuantifier() != null && aggCall.getFunctionQuantifier().getValue().equals(SqlSelectKeyword.DISTINCT)) { isDistinct = true;
final SqlLiteral quantifier = call.getFunctionQuantifier(); if (quantifier != null) { quantifier.unparse(writer, 0, 0);
final SqlLiteral quantifier = call.getFunctionQuantifier(); if (quantifier != null) { quantifier.unparse(writer, 0, 0);