for (RelDataTypeField targetField : targetFields) { fields.add( Pair.of(SqlUtil.deriveAliasFromOrdinal(fields.size()), targetField.getType()));
/** * Creates the SELECT statement that putatively feeds rows into an UPDATE * statement to be updated. * * @param call Call to the UPDATE operator * @return select statement */ protected SqlSelect createSourceSelectForUpdate(SqlUpdate call) { final SqlNodeList selectList = new SqlNodeList(SqlParserPos.ZERO); selectList.add(SqlIdentifier.star(SqlParserPos.ZERO)); int ordinal = 0; for (SqlNode exp : call.getSourceExpressionList()) { // Force unique aliases to avoid a duplicate for Y with // SET X=Y String alias = SqlUtil.deriveAliasFromOrdinal(ordinal); selectList.add(SqlValidatorUtil.addAlias(exp, alias)); ++ordinal; } SqlNode sourceTable = call.getTargetTable(); if (call.getAlias() != null) { sourceTable = SqlValidatorUtil.addAlias( sourceTable, call.getAlias().getSimple()); } return new SqlSelect(SqlParserPos.ZERO, null, selectList, sourceTable, call.getCondition(), null, null, null, null, null, null); }
private RelDataType toStruct(RelDataType type) { if (type.isStruct()) { return type; } return typeFactory.builder() .add(SqlUtil.deriveAliasFromOrdinal(0), type) .build(); }
private RelDataType toStruct(RelDataType type) { if (type.isStruct()) { return type; } return typeFactory.builder() .add(SqlUtil.deriveAliasFromOrdinal(0), type) .build(); }
/** Quickly prepares a simple SQL statement, circumventing the usual * preparation process. */ private <T> CalciteSignature<T> simplePrepare(Context context, String sql) { final JavaTypeFactory typeFactory = context.getTypeFactory(); final RelDataType x = typeFactory.builder() .add(SqlUtil.deriveAliasFromOrdinal(0), SqlTypeName.INTEGER) .build(); @SuppressWarnings("unchecked") final List<T> list = (List) ImmutableList.of(1); final List<String> origin = null; final List<List<String>> origins = Collections.nCopies(x.getFieldCount(), origin); final List<ColumnMetaData> columns = getColumnMetaDataList(typeFactory, x, x, origins); final Meta.CursorFactory cursorFactory = Meta.CursorFactory.deduce(columns, null); return new CalciteSignature<>( sql, ImmutableList.of(), ImmutableMap.of(), x, columns, cursorFactory, context.getRootSchema(), ImmutableList.of(), -1, dataContext -> Linq4j.asEnumerable(list), Meta.StatementType.SELECT); }
/** Quickly prepares a simple SQL statement, circumventing the usual * preparation process. */ private <T> CalciteSignature<T> simplePrepare(Context context, String sql) { final JavaTypeFactory typeFactory = context.getTypeFactory(); final RelDataType x = typeFactory.builder() .add(SqlUtil.deriveAliasFromOrdinal(0), SqlTypeName.INTEGER) .build(); @SuppressWarnings("unchecked") final List<T> list = (List) ImmutableList.of(1); final List<String> origin = null; final List<List<String>> origins = Collections.nCopies(x.getFieldCount(), origin); final List<ColumnMetaData> columns = getColumnMetaDataList(typeFactory, x, x, origins); final Meta.CursorFactory cursorFactory = Meta.CursorFactory.deduce(columns, null); return new CalciteSignature<>( sql, ImmutableList.of(), ImmutableMap.of(), x, columns, cursorFactory, context.getRootSchema(), ImmutableList.of(), -1, dataContext -> Linq4j.asEnumerable(list), Meta.StatementType.SELECT); }
final RelDataType x = typeFactory.builder() .add(SqlUtil.deriveAliasFromOrdinal(0), SqlTypeName.INTEGER) .build(); @SuppressWarnings("unchecked")
fieldNameList.add(SqlUtil.deriveAliasFromOrdinal(j));
fieldNameList.add(SqlUtil.deriveAliasFromOrdinal(j));
fieldNameList.add(SqlUtil.deriveAliasFromOrdinal(j));
for (RelDataTypeField targetField : targetFields) { fields.add( Pair.of(SqlUtil.deriveAliasFromOrdinal(fields.size()), targetField.getType()));
for (RelDataTypeField targetField : targetFields) { fields.add( Pair.of(SqlUtil.deriveAliasFromOrdinal(fields.size()), targetField.getType()));
return null; } else { return SqlUtil.deriveAliasFromOrdinal(ordinal);
return null; } else { return SqlUtil.deriveAliasFromOrdinal(ordinal);
builder.add(SqlUtil.deriveAliasFromOrdinal(field.getIndex()), ret);
/** * Creates the SELECT statement that putatively feeds rows into an UPDATE * statement to be updated. * * @param call Call to the UPDATE operator * @return select statement */ protected SqlSelect createSourceSelectForUpdate(SqlUpdate call) { final SqlNodeList selectList = new SqlNodeList(SqlParserPos.ZERO); selectList.add(SqlIdentifier.star(SqlParserPos.ZERO)); int ordinal = 0; for (SqlNode exp : call.getSourceExpressionList()) { // Force unique aliases to avoid a duplicate for Y with // SET X=Y String alias = SqlUtil.deriveAliasFromOrdinal(ordinal); selectList.add(SqlValidatorUtil.addAlias(exp, alias)); ++ordinal; } SqlNode sourceTable = call.getTargetTable(); if (call.getAlias() != null) { sourceTable = SqlValidatorUtil.addAlias( sourceTable, call.getAlias().getSimple()); } return new SqlSelect(SqlParserPos.ZERO, null, selectList, sourceTable, call.getCondition(), null, null, null, null, null, null); }
/** * Creates the SELECT statement that putatively feeds rows into an UPDATE * statement to be updated. * * @param call Call to the UPDATE operator * @return select statement */ protected SqlSelect createSourceSelectForUpdate(SqlUpdate call) { final SqlNodeList selectList = new SqlNodeList(SqlParserPos.ZERO); selectList.add(SqlIdentifier.star(SqlParserPos.ZERO)); int ordinal = 0; for (SqlNode exp : call.getSourceExpressionList()) { // Force unique aliases to avoid a duplicate for Y with // SET X=Y String alias = SqlUtil.deriveAliasFromOrdinal(ordinal); selectList.add(SqlValidatorUtil.addAlias(exp, alias)); ++ordinal; } SqlNode sourceTable = call.getTargetTable(); if (call.getAlias() != null) { sourceTable = SqlValidatorUtil.addAlias( sourceTable, call.getAlias().getSimple()); } return new SqlSelect(SqlParserPos.ZERO, null, selectList, sourceTable, call.getCondition(), null, null, null, null, null, null); }
builder.add(SqlUtil.deriveAliasFromOrdinal(field.getIndex()), ret);
builder.addAll(type.getComponentType().getFieldList()); } else { builder.add(SqlUtil.deriveAliasFromOrdinal(operand), type.getComponentType());
builder.addAll(type.getComponentType().getFieldList()); } else { builder.add(SqlUtil.deriveAliasFromOrdinal(operand), type.getComponentType());