public SqlNode visit(SqlLiteral literal) { // Ordinal markers, e.g. 'select a, b from t order by 2'. // Only recognize them if they are the whole expression, // and if the dialect permits. if (literal == root && getConformance().isSortByOrdinal()) { switch (literal.getTypeName()) { case DECIMAL: case DOUBLE: final int intValue = literal.intValue(false); if (intValue >= 0) { if (intValue < 1 || intValue > aliasList.size()) { throw newValidationError( literal, RESOURCE.orderByOrdinalOutOfRange()); } // SQL ordinals are 1-based, but Sort's are 0-based int ordinal = intValue - 1; return nthSelectItem(ordinal, literal.getParserPosition()); } break; } } return super.visit(literal); }
public void validateLiteral(SqlLiteral literal) { switch (literal.getTypeName()) { case DECIMAL:
switch (literal.getTypeName()) { case DECIMAL: case DOUBLE:
private boolean isNull(SqlNode sqlNode) { return sqlNode instanceof SqlLiteral && ((SqlLiteral) sqlNode).getTypeName() == SqlTypeName.NULL; } });
private boolean isNull(SqlNode sqlNode) { return sqlNode instanceof SqlLiteral && ((SqlLiteral) sqlNode).getTypeName() == SqlTypeName.NULL; } });
public SqlJoin(SqlParserPos pos, SqlNode left, SqlLiteral natural, SqlLiteral joinType, SqlNode right, SqlLiteral conditionType, SqlNode condition) { super(pos); this.left = left; this.natural = Objects.requireNonNull(natural); this.joinType = Objects.requireNonNull(joinType); this.right = right; this.conditionType = Objects.requireNonNull(conditionType); this.condition = condition; Preconditions.checkArgument(natural.getTypeName() == SqlTypeName.BOOLEAN); Objects.requireNonNull(conditionType.symbolValue(JoinConditionType.class)); Objects.requireNonNull(joinType.symbolValue(JoinType.class)); }
public SqlJoin(SqlParserPos pos, SqlNode left, SqlLiteral natural, SqlLiteral joinType, SqlNode right, SqlLiteral conditionType, SqlNode condition) { super(pos); this.left = left; this.natural = Objects.requireNonNull(natural); this.joinType = Objects.requireNonNull(joinType); this.right = right; this.conditionType = Objects.requireNonNull(conditionType); this.condition = condition; Preconditions.checkArgument(natural.getTypeName() == SqlTypeName.BOOLEAN); Objects.requireNonNull(conditionType.symbolValue(JoinConditionType.class)); Objects.requireNonNull(joinType.symbolValue(JoinType.class)); }
@Override public SqlNode visit(SqlLiteral literal) { if (!isNull(literal) && literal.getTypeName() != SqlTypeName.SYMBOL) { literalSet.add(literal); } return literal; }
@Override public SqlNode visit(SqlLiteral literal) { if (!isNull(literal) && literal.getTypeName() != SqlTypeName.SYMBOL) { literalSet.add(literal); } return literal; }
private static Object sqlLiteralToObject(final SqlLiteral literal) { final Object object = literal.getValue(); final SqlTypeName typeName = literal.getTypeName(); switch (typeName) { case DECIMAL: {
/** * Extracts the string value from a string literal, a chain of string * literals, or a CAST of a string literal. * * @deprecated Use {@link #value(SqlNode)} */ @Deprecated // to be removed before 2.0 public static String stringValue(SqlNode node) { if (node instanceof SqlLiteral) { SqlLiteral literal = (SqlLiteral) node; assert SqlTypeUtil.inCharFamily(literal.getTypeName()); return literal.value.toString(); } else if (SqlUtil.isLiteralChain(node)) { final SqlLiteral literal = SqlLiteralChainOperator.concatenateOperands((SqlCall) node); assert SqlTypeUtil.inCharFamily(literal.getTypeName()); return literal.value.toString(); } else if (node instanceof SqlCall && ((SqlCall) node).getOperator() == SqlStdOperatorTable.CAST) { //noinspection deprecation return stringValue(((SqlCall) node).operand(0)); } else { throw new AssertionError("invalid string literal: " + node); } }
/** * Extracts the string value from a string literal, a chain of string * literals, or a CAST of a string literal. * * @deprecated Use {@link #value(SqlNode)} */ @Deprecated // to be removed before 2.0 public static String stringValue(SqlNode node) { if (node instanceof SqlLiteral) { SqlLiteral literal = (SqlLiteral) node; assert SqlTypeUtil.inCharFamily(literal.getTypeName()); return literal.value.toString(); } else if (SqlUtil.isLiteralChain(node)) { final SqlLiteral literal = SqlLiteralChainOperator.concatenateOperands((SqlCall) node); assert SqlTypeUtil.inCharFamily(literal.getTypeName()); return literal.value.toString(); } else if (node instanceof SqlCall && ((SqlCall) node).getOperator() == SqlStdOperatorTable.CAST) { //noinspection deprecation return stringValue(((SqlCall) node).operand(0)); } else { throw new AssertionError("invalid string literal: " + node); } }
private static OptionValue createOptionValue(final String name, final OptionValue.OptionType type, final SqlLiteral literal) { final Object object = literal.getValue(); final SqlTypeName typeName = literal.getTypeName(); switch (typeName) { case DECIMAL: {
if (node instanceof SqlLiteral) { SqlLiteral literal = (SqlLiteral) node; if (literal.getTypeName() == SqlTypeName.NULL) { assert null == literal.getValue(); return true;
if (node instanceof SqlLiteral) { SqlLiteral literal = (SqlLiteral) node; if (literal.getTypeName() == SqlTypeName.NULL) { assert null == literal.getValue(); return true;
public SqlNode visit(SqlLiteral literal) { // Ordinal markers, e.g. 'select a, b from t order by 2'. // Only recognize them if they are the whole expression, // and if the dialect permits. if (literal == root && getConformance().isSortByOrdinal()) { switch (literal.getTypeName()) { case DECIMAL: case DOUBLE: final int intValue = literal.intValue(false); if (intValue >= 0) { if (intValue < 1 || intValue > aliasList.size()) { throw newValidationError( literal, RESOURCE.orderByOrdinalOutOfRange()); } // SQL ordinals are 1-based, but Sort's are 0-based int ordinal = intValue - 1; return nthSelectItem(ordinal, literal.getParserPosition()); } break; } } return super.visit(literal); }
public SqlNode visit(SqlLiteral literal) { // Ordinal markers, e.g. 'select a, b from t order by 2'. // Only recognize them if they are the whole expression, // and if the dialect permits. if (literal == root && getConformance().isSortByOrdinal()) { switch (literal.getTypeName()) { case DECIMAL: case DOUBLE: final int intValue = literal.intValue(false); if (intValue >= 0) { if (intValue < 1 || intValue > aliasList.size()) { throw newValidationError( literal, RESOURCE.orderByOrdinalOutOfRange()); } // SQL ordinals are 1-based, but Sort's are 0-based int ordinal = intValue - 1; return nthSelectItem(ordinal, literal.getParserPosition()); } break; } } return super.visit(literal); }
switch (literal.getTypeName()) { case DECIMAL: case DOUBLE:
switch (literal.getTypeName()) { case DECIMAL: case DOUBLE:
} else { if (rand.getTypeName() == SqlTypeName.BINARY) { BitString bs = (BitString) rand.getValue(); writer.literal("'" + bs.toHexString() + "'");