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); }
on = JoinConditionType.ON.symbol(getPos()); condition = Expression(ExprContext.ACCEPT_SUB_QUERY); {if (true) return new SqlJoin(joinType.getParserPosition(), e, natural, using = JoinConditionType.USING.symbol(getPos()); list = ParenthesizedSimpleIdentifierList(); {if (true) return new SqlJoin(joinType.getParserPosition(), e, natural, new SqlNodeList(list.getList(), Span.of(using).end(this)));} } else { {if (true) return new SqlJoin(joinType.getParserPosition(), e, natural, joinType, e2, JoinConditionType.NONE.symbol(joinType.getParserPosition()), null);}
literal.getParserPosition(), typeFactory.getTypeSystem()); Util.discard(values);
joinConditionType = JoinConditionType.ON.symbol(getPos()); condition = Expression(ExprContext.ACCEPT_SUB_QUERY); e = new SqlJoin(joinType.getParserPosition(), e, natural, joinConditionType = JoinConditionType.USING.symbol(getPos()); list = ParenthesizedSimpleIdentifierList(); e = new SqlJoin(joinType.getParserPosition(), e, natural, new SqlNodeList(list.getList(), Span.of(joinConditionType).end(this))); } else { e = new SqlJoin(joinType.getParserPosition(), e, natural, joinType, e2, JoinConditionType.NONE.symbol(joinType.getParserPosition()), null); joinType = JoinType.COMMA.symbol(getPos()); e2 = TableRef(); e = new SqlJoin(joinType.getParserPosition(), e, SqlLiteral.createBoolean(false, joinType.getParserPosition()), joinType, e2,
on = JoinConditionType.ON.symbol(getPos()); condition = Expression(ExprContext.ACCEPT_SUB_QUERY); {if (true) return new SqlJoin(joinType.getParserPosition(), e, natural, using = JoinConditionType.USING.symbol(getPos()); list = ParenthesizedSimpleIdentifierList(); {if (true) return new SqlJoin(joinType.getParserPosition(), e, natural, new SqlNodeList(list.getList(), Span.of(using).end(this)));} } else { {if (true) return new SqlJoin(joinType.getParserPosition(), e, natural, joinType, e2, JoinConditionType.NONE.symbol(joinType.getParserPosition()), null);}
joinConditionType = JoinConditionType.ON.symbol(getPos()); condition = Expression(ExprContext.ACCEPT_SUB_QUERY); e = new SqlJoin(joinType.getParserPosition(), e, natural, joinConditionType = JoinConditionType.USING.symbol(getPos()); list = ParenthesizedSimpleIdentifierList(); e = new SqlJoin(joinType.getParserPosition(), e, natural, new SqlNodeList(list.getList(), Span.of(joinConditionType).end(this))); } else { e = new SqlJoin(joinType.getParserPosition(), e, natural, joinType, e2, JoinConditionType.NONE.symbol(joinType.getParserPosition()), null); joinType = JoinType.COMMA.symbol(getPos()); e2 = TableRef(); e = new SqlJoin(joinType.getParserPosition(), e, SqlLiteral.createBoolean(false, joinType.getParserPosition()), joinType, e2,
on = JoinConditionType.ON.symbol(getPos()); condition = Expression(ExprContext.ACCEPT_SUB_QUERY); {if ("" != null) return new SqlJoin(joinType.getParserPosition(), e, natural, using = JoinConditionType.USING.symbol(getPos()); list = ParenthesizedSimpleIdentifierList(); {if ("" != null) return new SqlJoin(joinType.getParserPosition(), e, natural, new SqlNodeList(list.getList(), Span.of(using).end(this)));} } else { {if ("" != null) return new SqlJoin(joinType.getParserPosition(), e, natural, joinType, e2, JoinConditionType.NONE.symbol(joinType.getParserPosition()), null);}
public SqlParserPos getReflectionIdPos() { return reflectionId.getParserPosition(); }
public SqlParserPos getMaterializationIdPos() { return materializationId.getParserPosition(); }
joinConditionType = JoinConditionType.ON.symbol(getPos()); condition = Expression(ExprContext.ACCEPT_SUB_QUERY); e = new SqlJoin(joinType.getParserPosition(), e, natural, joinConditionType = JoinConditionType.USING.symbol(getPos()); list = ParenthesizedSimpleIdentifierList(); e = new SqlJoin(joinType.getParserPosition(), e, natural, new SqlNodeList(list.getList(), Span.of(joinConditionType).end(this))); } else { e = new SqlJoin(joinType.getParserPosition(), e, natural, joinType, e2, JoinConditionType.NONE.symbol(joinType.getParserPosition()), null); joinType = JoinType.COMMA.symbol(getPos()); e2 = TableRef(); e = new SqlJoin(joinType.getParserPosition(), e, SqlLiteral.createBoolean(false, joinType.getParserPosition()), joinType, e2,
@Override protected SqlAbstractStringLiteral concat1(List<SqlLiteral> literals) { return new SqlVarCharStringLiteral( NlsString.concat(literals.stream().map(F::apply).collect(Collectors.toList())), literals.get(0).getParserPosition()); } }
protected SqlAbstractStringLiteral concat1(List<SqlLiteral> literals) { return new SqlBinaryStringLiteral( BitString.concat( Util.transform(literals, literal -> ((SqlBinaryStringLiteral) literal).getBitString())), literals.get(0).getParserPosition()); } }
protected SqlAbstractStringLiteral concat1(List<SqlLiteral> literals) { return new SqlCharStringLiteral( NlsString.concat( Util.transform(literals, literal -> ((SqlCharStringLiteral) literal).getNlsString())), literals.get(0).getParserPosition()); } }
protected SqlAbstractStringLiteral concat1(List<SqlLiteral> literals) { return new SqlCharStringLiteral( NlsString.concat( Util.transform(literals, literal -> ((SqlCharStringLiteral) literal).getNlsString())), literals.get(0).getParserPosition()); } }
protected SqlAbstractStringLiteral concat1(List<SqlLiteral> literals) { return new SqlBinaryStringLiteral( BitString.concat( Util.transform(literals, literal -> ((SqlBinaryStringLiteral) literal).getBitString())), literals.get(0).getParserPosition()); } }
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); }
@Override public void unparseCall(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) { switch (call.getKind()) { case FLOOR: if (call.operandCount() != 2) { super.unparseCall(writer, call, leftPrec, rightPrec); return; } final SqlLiteral timeUnitNode = call.operand(1); final TimeUnitRange timeUnit = timeUnitNode.getValueAs(TimeUnitRange.class); SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, timeUnit.name(), timeUnitNode.getParserPosition()); SqlFloorFunction.unparseDatetimeFunction(writer, call2, "DATE_TRUNC", false); break; default: super.unparseCall(writer, call, leftPrec, rightPrec); } } }
@Override public void unparseCall(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) { switch (call.getKind()) { case FLOOR: if (call.operandCount() != 2) { super.unparseCall(writer, call, leftPrec, rightPrec); return; } final SqlLiteral timeUnitNode = call.operand(1); final TimeUnitRange timeUnit = timeUnitNode.getValueAs(TimeUnitRange.class); SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, timeUnit.name(), timeUnitNode.getParserPosition()); SqlFloorFunction.unparseDatetimeFunction(writer, call2, "DATE_TRUNC", false); break; default: super.unparseCall(writer, call, leftPrec, rightPrec); } } }
@Override public void unparseCall(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) { switch (call.getKind()) { case FLOOR: if (call.operandCount() != 2) { super.unparseCall(writer, call, leftPrec, rightPrec); return; } final SqlLiteral timeUnitNode = call.operand(1); final TimeUnitRange timeUnit = timeUnitNode.getValueAs(TimeUnitRange.class); final String translatedLit = convertTimeUnit(timeUnit); SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, translatedLit, timeUnitNode.getParserPosition()); SqlFloorFunction.unparseDatetimeFunction(writer, call2, "TRUNC", true); break; default: super.unparseCall(writer, call, leftPrec, rightPrec); } }
@Override public void unparseCall(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) { switch (call.getKind()) { case FLOOR: if (call.operandCount() != 2) { super.unparseCall(writer, call, leftPrec, rightPrec); return; } final SqlLiteral timeUnitNode = call.operand(1); final TimeUnitRange timeUnit = timeUnitNode.getValueAs(TimeUnitRange.class); final String translatedLit = convertTimeUnit(timeUnit); SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, translatedLit, timeUnitNode.getParserPosition()); SqlFloorFunction.unparseDatetimeFunction(writer, call2, "TRUNC", true); break; default: super.unparseCall(writer, call, leftPrec, rightPrec); } }