BigDecimal rate = samplePercentage.bigDecimalValue(); if (rate.compareTo(BigDecimal.ZERO) < 0 || rate.compareTo(ONE_HUNDRED) > 0)
public static SqlNumericLiteral createNegative( SqlNumericLiteral num, SqlParserPos pos) { return new SqlNumericLiteral( ((BigDecimal) num.getValue()).negate(), num.getPrec(), num.getScale(), num.isExact(), pos); }
private void doWriteFetchNext(SqlNode fetch, SqlNode offset) { if (offset == null && !configurer.allowNoOffset()) offset = SqlLiteral.createExactNumeric("0", SqlParserPos.ZERO); if (fetch != null && !configurer.allowNoOrderByWithFetch() && lastFrame != null && lastFrame.getFrameType() != FrameTypeEnum.ORDER_BY_LIST) { // MSSQL requires ORDER_BY list for FETCH clause, so must append one here. DUMMY_ORDER_BY_NODE.unparse(this, 0, 0); } if (offset != null) { this.newlineAndIndent(); final Frame offsetFrame = this.startList(FrameTypeEnum.OFFSET); this.keyword("OFFSET"); offset.unparse(this, -1, -1); this.keyword("ROWS"); this.endList(offsetFrame); } if (fetch != null) { if (!configurer.allowFetchNoRows() && fetch instanceof SqlNumericLiteral) if (((SqlNumericLiteral) fetch).toValue().equals("0")) fetch = SqlLiteral.createExactNumeric("1", SqlParserPos.ZERO); this.newlineAndIndent(); final Frame fetchFrame = this.startList(FrameTypeEnum.FETCH); this.keyword("FETCH"); this.keyword("NEXT"); fetch.unparse(this, -1, -1); this.keyword("ROWS"); this.keyword("ONLY"); this.endList(fetchFrame); } }
@Override public SqlNumericLiteral clone(SqlParserPos pos) { return new SqlNumericLiteral((BigDecimal) value, getPrec(), getScale(), isExact, pos); }
@Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) { if (opBinding instanceof SqlCallBinding && (((SqlCallBinding) opBinding).operand(1) instanceof SqlNumericLiteral)) { int precision = ((SqlNumericLiteral) ((SqlCallBinding) opBinding).operand(1)).intValue(true); RelDataType sqlType = opBinding.getTypeFactory().createSqlType(SqlTypeName.VARCHAR, Math.max(precision, 0)); return opBinding.getTypeFactory().createTypeWithNullability(sqlType, isNullable(opBinding.collectOperandTypes())); } return createCalciteTypeWithNullability( opBinding.getTypeFactory(), SqlTypeName.VARCHAR, isNullable(opBinding.collectOperandTypes())); } }
&& select.getFetch() instanceof SqlNumericLiteral) { SqlNumericLiteral limitNum = (SqlNumericLiteral) select.getFetch(); if (((BigDecimal) limitNum.getValue()).intValue() < 2) { return plan;
private Expression visitSqlSpecialOperator(SqlSpecialOperator specialOperator, List<SqlNode> operands) { if (specialOperator.getName().equalsIgnoreCase("ITEM")) { Expression left = operands.get(0).accept(this); SqlNode right = operands.get(1); if (right instanceof SqlNumericLiteral) { SqlNumericLiteral index = (SqlNumericLiteral) right; if (!index.isInteger()) { throw new IllegalArgumentException("Invalid array index " + index); } return new ArrayFieldExpression(left, Integer.parseInt(index.toValue())); } else if (right instanceof SqlCharStringLiteral) { String key = ((SqlCharStringLiteral) right).toValue(); return new MapFieldExpression(left, key); } else { throw new IllegalArgumentException("Item right operand '" + right + "' must be numeric or character type"); } } else if (specialOperator.getName().equalsIgnoreCase("AS")) { Expression left = operands.get(0).accept(this); String alias = operands.get(1).toString(); return new AsExpression(left, alias); } else { throw new UnsupportedOperationException("Operator " + specialOperator + " not implemented"); } }
public static SqlNumericLiteral createApproxNumeric( String s, SqlParserPos pos) { BigDecimal value = SqlParserUtil.parseDecimal(s); return new SqlNumericLiteral(value, null, null, false, pos); }
case "ds_set_id": if (rowList.get(i) instanceof SqlNumericLiteral) { view.setDsSetId(((SqlNumericLiteral) rowList.get(i)).longValue(true)); } else { throw new SQLException("Incorrect argument type to variable 'ds_set_id'"); case "cost": if (rowList.get(i) instanceof SqlNumericLiteral) { view.setCost(((SqlNumericLiteral) rowList.get(i)).longValue(true)); } else { throw new SQLException("Incorrect argument type to variable 'cost'"); case "destination_id": if (rowList.get(i) instanceof SqlNumericLiteral) { view.setDestinationId(((SqlNumericLiteral) rowList.get(i)).longValue(true)); } else { throw new SQLException("Incorrect argument type to variable 'destination_id'");
if (rowList.get(i) instanceof SqlNumericLiteral) { dbSpecificColumns.put("dbtap_id", ((SqlNumericLiteral) rowList.get(i)).intValue(true)); } else { throw new SQLException("Incorrect argument type to variable"
@Override public SqlNumericLiteral clone(SqlParserPos pos) { return new SqlNumericLiteral((BigDecimal) value, getPrec(), getScale(), isExact, pos); }
&& select.getFetch() instanceof SqlNumericLiteral) { SqlNumericLiteral limitNum = (SqlNumericLiteral) select.getFetch(); if (((BigDecimal) limitNum.getValue()).intValue() < 2) { return plan;
public static SqlNumericLiteral createApproxNumeric( String s, SqlParserPos pos) { BigDecimal value = SqlParserUtil.parseDecimal(s); return new SqlNumericLiteral(value, null, null, false, pos); }
BigDecimal rate = samplePercentage.bigDecimalValue(); if (rate.compareTo(BigDecimal.ZERO) < 0 || rate.compareTo(ONE_HUNDRED) > 0)
public static SqlNumericLiteral createNegative( SqlNumericLiteral num, SqlParserPos pos) { return new SqlNumericLiteral( ((BigDecimal) num.getValue()).negate(), num.getPrec(), num.getScale(), num.isExact(), pos); }
@Override public void unparse(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) { call.operand(0).unparse(writer, this.getLeftPrec(), this.getRightPrec()); int startNum = ((SqlNumericLiteral) call.operand(1)).intValue(true); SqlNumericLiteral endRepNum = call.operand(2); boolean isReluctant = ((SqlLiteral) call.operand(3)).booleanValue(); int endNum = endRepNum.intValue(true); if (startNum == endNum) { writer.keyword("{ " + startNum + " }");
public void unparse( SqlWriter writer, int leftPrec, int rightPrec) { writer.literal(toValue()); }
&& select.getFetch() instanceof SqlNumericLiteral) { SqlNumericLiteral limitNum = (SqlNumericLiteral) select.getFetch(); if (((BigDecimal) limitNum.getValue()).intValue() < 2) { return plan;