private boolean sameRowTypeProjectionsFields(RelDataType oldRowType, RelDataType newRowType) { for (RelDataTypeField oldField : oldRowType.getFieldList()) { String oldProjName = oldField.getName(); boolean match = false; for (RelDataTypeField newField : newRowType.getFieldList()) { if (oldProjName.equals(newField.getName())) { match = true; break; } } if (!match) { return false; } } return true; } }
@Override public RexNode visitInputRef(RexInputRef inputRef) { RelDataTypeField f = rType.getFieldList().get(inputRef.getIndex()); if (partCols.contains(f.getName())) { return inputRef; } else { return null; } }
@Override public ExprNodeDesc visitInputRef(RexInputRef inputRef) { RelDataTypeField f = inputRowType.getFieldList().get(inputRef.getIndex()); return new ExprNodeColumnDesc(TypeConverter.convert(f.getType()), f.getName(), tabAlias, inputVCols.contains(inputRef.getIndex())); }
for (RelDataTypeField f : this.rowType.getFieldList()) { nameToColIndxMap.put(f.getName(), f.getIndex()); ColumnInfo cInfo; VirtualColumn vc; for (RelDataTypeField f : newRowType.getFieldList()) { originalColIndx = nameToColIndxMap.get(f.getName()); if ((cInfo = hiveNonPartitionColsMap.get(originalColIndx)) != null) { newHiveNonPartitionCols.add(new ColumnInfo(cInfo)); } else if ((cInfo = hivePartitionColsMap.get(originalColIndx)) != null) { newHivePartitionCols.add(new ColumnInfo(cInfo)); } else if ((vc = virtualColInfoMap.get(originalColIndx)) != null) { newHiveVirtualCols.add(vc); } else { throw new RuntimeException("Copy encountered a column not seen in original TS");
@Override public Object[] apply(final RelDataTypeField field) { final RelDataType type = field.getType(); boolean isNumeric = SqlTypeName.NUMERIC_TYPES.contains(type.getSqlTypeName()); boolean isCharacter = SqlTypeName.CHAR_TYPES.contains(type.getSqlTypeName()); boolean isDateTime = SqlTypeName.DATETIME_TYPES.contains(type.getSqlTypeName()); return new Object[]{ CATALOG_NAME, // TABLE_CATALOG schemaName, // TABLE_SCHEMA tableName, // TABLE_NAME field.getName(), // COLUMN_NAME String.valueOf(field.getIndex()), // ORDINAL_POSITION "", // COLUMN_DEFAULT type.isNullable() ? "YES" : "NO", // IS_NULLABLE type.getSqlTypeName().toString(), // DATA_TYPE null, // CHARACTER_MAXIMUM_LENGTH null, // CHARACTER_OCTET_LENGTH isNumeric ? String.valueOf(type.getPrecision()) : null, // NUMERIC_PRECISION isNumeric ? "10" : null, // NUMERIC_PRECISION_RADIX isNumeric ? String.valueOf(type.getScale()) : null, // NUMERIC_SCALE isDateTime ? String.valueOf(type.getPrecision()) : null, // DATETIME_PRECISION isCharacter ? type.getCharset().name() : null, // CHARACTER_SET_NAME isCharacter ? type.getCollation().getCollationName() : null, // COLLATION_NAME Long.valueOf(type.getSqlTypeName().getJdbcOrdinal()) // JDBC_TYPE (Druid extension) }; } }
public View(String name, String sql, RelDataType rowType, List<String> workspaceSchemaPath) { this(name, sql, rowType.getFieldList().stream() .map(f -> new FieldType(f.getName(), f.getType())) .collect(Collectors.toList()), workspaceSchemaPath); }
@Override public ExprNodeDesc visitInputRef(RexInputRef inputRef) { RelDataTypeField f = inputRowType.getFieldList().get(inputRef.getIndex()); return new ExprNodeColumnDesc(TypeConverter.convert(f.getType()), f.getName(), tabAlias, inputVCols.contains(inputRef.getIndex())); }
@Override public RexNode visitInputRef(RexInputRef inputRef) { RelDataTypeField f = rType.getFieldList().get(inputRef.getIndex()); if (partCols.contains(f.getName())) { return inputRef; } else { return null; } }
for (RelDataTypeField f : this.rowType.getFieldList()) { nameToColIndxMap.put(f.getName(), f.getIndex()); ColumnInfo cInfo; VirtualColumn vc; for (RelDataTypeField f : newRowType.getFieldList()) { originalColIndx = nameToColIndxMap.get(f.getName()); if ((cInfo = hiveNonPartitionColsMap.get(originalColIndx)) != null) { newHiveNonPartitionCols.add(new ColumnInfo(cInfo)); } else if ((cInfo = hivePartitionColsMap.get(originalColIndx)) != null) { newHivePartitionCols.add(new ColumnInfo(cInfo)); } else if ((vc = virtualColInfoMap.get(originalColIndx)) != null) { newHiveVirtualCols.add(vc); } else { throw new RuntimeException("Copy encountered a column not seen in original TS");
ColumnRowType buildColumnRowType() { ArrayList<TblColRef> colRefs = Lists.newArrayListWithCapacity(rowType.getFieldCount()); for(RelDataTypeField r:rowType.getFieldList()){ colRefs.add(TblColRef.newInnerColumn(r.getName(), TblColRef.InnerDataTypeEnum.LITERAL)); } return new ColumnRowType(colRefs); }
/** As {@link #field(int, int, int)}, but if {@code alias} is true, the method * may apply an alias to make sure that the field has the same name as in the * input frame. If no alias is applied the expression is definitely a * {@link RexInputRef}. */ private RexNode field(int inputCount, int inputOrdinal, int fieldOrdinal, boolean alias) { final Frame frame = peek_(inputCount, inputOrdinal); final RelNode input = frame.rel; final RelDataType rowType = input.getRowType(); if (fieldOrdinal < 0 || fieldOrdinal > rowType.getFieldCount()) { throw new IllegalArgumentException("field ordinal [" + fieldOrdinal + "] out of range; input fields are: " + rowType.getFieldNames()); } final RelDataTypeField field = rowType.getFieldList().get(fieldOrdinal); final int offset = inputOffset(inputCount, inputOrdinal); final RexInputRef ref = cluster.getRexBuilder() .makeInputRef(field.getType(), offset + fieldOrdinal); final RelDataTypeField aliasField = frame.fields().get(fieldOrdinal); if (!alias || field.getName().equals(aliasField.getName())) { return ref; } else { return alias(ref, aliasField.getName()); } }
public void setReturnTupleInfo(RelDataType rowType, ColumnRowType columnRowType) { TupleInfo info = new TupleInfo(); List<RelDataTypeField> fieldList = rowType.getFieldList(); for (int i = 0; i < fieldList.size(); i++) { RelDataTypeField field = fieldList.get(i); TblColRef col = columnRowType == null ? null : columnRowType.getColumnByIndex(i); info.setField(field.getName(), col, i); } this.returnTupleInfo = info; }
private List<String> fieldNames(RelDataType relDataType) { List<String> names = new ArrayList<>(); for (RelDataTypeField rdtf : relDataType.getFieldList()) { names.add(rdtf.getName()); } return names; }
Schema(TableFunctionScan select, String alias) { for (RelDataTypeField field : select.getRowType().getFieldList()) { add(new ColumnInfo(alias, field.getName())); } }