Refine search
public static List<String> getFieldNames(List<Integer> inputRefs, RelNode inputRel) { List<String> fieldNames = new ArrayList<String>(); List<String> schemaNames = inputRel.getRowType().getFieldNames(); for (Integer iRef : inputRefs) { fieldNames.add(schemaNames.get(iRef)); } return fieldNames; }
public static List<String> getFieldNames(List<Integer> inputRefs, RelNode inputRel) { List<String> fieldNames = new ArrayList<String>(); List<String> schemaNames = inputRel.getRowType().getFieldNames(); for (Integer iRef : inputRefs) { fieldNames.add(schemaNames.get(iRef)); } return fieldNames; }
private void getInputRefMapping(RexNode condition, RelDataType rowType, HashMap<String, String> mapping) { if (condition instanceof RexCall) { for (RexNode op : ((RexCall) condition).getOperands()) { getInputRefMapping(op, rowType, mapping); } } else if (condition instanceof RexInputRef) { mapping.put(condition.toString(), rowType.getFieldNames().get(condition.hashCode())); } }
private RelNode projectLeftOuterSide(RelNode srcRel, int numColumns) throws SemanticException { RowResolver iRR = relToHiveRR.get(srcRel); RowResolver oRR = new RowResolver(); RowResolver.add(oRR, iRR, numColumns); List<RexNode> calciteColLst = new ArrayList<RexNode>(); List<String> oFieldNames = new ArrayList<String>(); RelDataType iType = srcRel.getRowType(); for (int i = 0; i < iType.getFieldCount(); i++) { RelDataTypeField fType = iType.getFieldList().get(i); String fName = iType.getFieldNames().get(i); calciteColLst.add(cluster.getRexBuilder().makeInputRef(fType.getType(), i)); oFieldNames.add(fName); } HiveRelNode selRel = HiveProject.create(srcRel, calciteColLst, oFieldNames); this.relToHiveColNameCalcitePosMap.put(selRel, buildHiveToCalciteColumnMap(oRR, selRel)); this.relToHiveRR.put(selRel, oRR); return selRel; }
List<String> colNamesInScanRowType = scanRowType.getFieldNames(); int tmp; for (int i = 0; i < colNamesInScanRowType.size(); i++) { tmp = colNameToPosInReloptHT.get(colNamesInScanRowType.get(i)); neededColIndxsFrmReloptHTBldr.add(tmp); if (tmp >= partColStartPosInrelOptHtRowtype) {
for (List<ForeignKeyCol> fkCols : fki.getForeignKeys().values()) { List<String> foreignKeyTableQualifiedName = qualifiedTblName; String parentDatabaseName = fkCols.get(0).parentDatabaseName; String parentTableName = fkCols.get(0).parentTableName; List<String> parentTableQualifiedName = new ArrayList<>(); if (parentDatabaseName != null && !parentDatabaseName.isEmpty()) { for (ForeignKeyCol fkCol : fkCols) { int fkPos; for (fkPos = 0; fkPos < rowType.getFieldNames().size(); fkPos++) { String fkColName = rowType.getFieldNames().get(fkPos); if (fkColName.equals(fkCol.childColName)) { break; if (fkPos == rowType.getFieldNames().size() || pkPos == parentTab.getAllCols().size()) { LOG.error("Column for foreign key definition " + fkCol + " not found");
private RelNode projectLeftOuterSide(RelNode srcRel, int numColumns) throws SemanticException { RowResolver iRR = relToHiveRR.get(srcRel); RowResolver oRR = new RowResolver(); RowResolver.add(oRR, iRR, numColumns); List<RexNode> calciteColLst = new ArrayList<RexNode>(); List<String> oFieldNames = new ArrayList<String>(); RelDataType iType = srcRel.getRowType(); for (int i = 0; i < iType.getFieldCount(); i++) { RelDataTypeField fType = iType.getFieldList().get(i); String fName = iType.getFieldNames().get(i); calciteColLst.add(cluster.getRexBuilder().makeInputRef(fType.getType(), i)); oFieldNames.add(fName); } HiveRelNode selRel = HiveProject.create(srcRel, calciteColLst, oFieldNames); this.relToHiveColNameCalcitePosMap.put(selRel, buildHiveToCalciteColumnMap(oRR, selRel)); this.relToHiveRR.put(selRel, oRR); return selRel; }
for (String pkColName : pki.getColNames().values()) { int pkPos; for (pkPos = 0; pkPos < rowType.getFieldNames().size(); pkPos++) { String colName = rowType.getFieldNames().get(pkPos); if (pkColName.equals(colName)) { break; if (pkPos == rowType.getFieldNames().size()) { LOG.error("Column for primary key definition " + pkColName + " not found"); for (UniqueConstraintCol ukCol : ukCols) { int ukPos; for (ukPos = 0; ukPos < rowType.getFieldNames().size(); ukPos++) { String colName = rowType.getFieldNames().get(ukPos); if (ukCol.colName.equals(colName)) { if(rowType.getFieldList().get(ukPos).getType().isNullable()) { if (ukPos == rowType.getFieldNames().size()) { LOG.error("Column for unique constraint definition " + ukCol.colName + " not found");
/** Infers the alias of an expression. * * <p>If the expression was created by {@link #alias}, replaces the expression * in the project list. */ private String inferAlias(List<RexNode> exprList, RexNode expr) { switch (expr.getKind()) { case INPUT_REF: final RexInputRef ref = (RexInputRef) expr; return peek(0).getRowType().getFieldNames().get(ref.getIndex()); case CAST: return inferAlias(exprList, ((RexCall) expr).getOperands().get(0)); case AS: final RexCall call = (RexCall) expr; for (;;) { final int i = exprList.indexOf(expr); if (i < 0) { break; } exprList.set(i, call.getOperands().get(0)); } return ((NlsString) ((RexLiteral) call.getOperands().get(1)).getValue()) .getValue(); default: return null; } }
for (String nnCol : nnc.getNotNullConstraints().values()) { int nnPos = -1; for (int i = 0; i < rowType.getFieldNames().size(); i++) { if (rowType.getFieldNames().get(i).equals(nnCol)) { nnPos = i; break; for (int i = 0; i < rowType.getFieldNames().size(); i++) { if (rowType.getFieldNames().get(i).equals(pkCol)) { pkPos = i; break;
/** Infers the alias of an expression. * * <p>If the expression was created by {@link #alias}, replaces the expression * in the project list. */ private String inferAlias(List<RexNode> exprList, RexNode expr) { switch (expr.getKind()) { case INPUT_REF: final RexInputRef ref = (RexInputRef) expr; return peek(0).getRowType().getFieldNames().get(ref.getIndex()); case CAST: return inferAlias(exprList, ((RexCall) expr).getOperands().get(0)); case AS: final RexCall call = (RexCall) expr; for (;;) { final int i = exprList.indexOf(expr); if (i < 0) { break; } exprList.set(i, call.getOperands().get(0)); } return ((NlsString) ((RexLiteral) call.getOperands().get(1)).getValue()) .getValue(); default: return null; } }
Map<Integer, ColumnInfo> posToNonPartColInfo = ht.getNonPartColInfoMap(); List<Integer> neededColIndxsFrmReloptHT = scanRel.getNeededColIndxsFrmReloptHT(); List<String> scanColNames = scanRel.getRowType().getFieldNames(); String tableAlias = scanRel.getConcatQbIDAlias(); colName = scanColNames.get(index); if (VColsMap.containsKey(index)) { vc = VColsMap.get(index);
gbInfo.outputColNames.addAll(aggRel.getRowType().getFieldNames()); for (int i : aggRel.getGroupSet()) { RexInputRef iRef = new RexInputRef(i, aggInputRel.getRowType().getFieldList() .get(i).getType()); tmpExprNodeDesc = iRef.accept(exprConv); gbInfo.gbKeys.add(tmpExprNodeDesc); gbInfo.gbKeyColNamesInInput.add(aggInputRel.getRowType().getFieldNames().get(i)); gbInfo.gbKeyTypes.add(tmpExprNodeDesc.getTypeInfo()); && (aggRel.getAggCallList().get(aggRel.getAggCallList().size() - 1).getAggregation() == HiveGroupingID.INSTANCE)) { gbInfo.grpIdFunctionNeeded = true;
belowProjectExprs.add(project.getChildExps().get(i)); belowProjectColumnNames.add(project.getRowType().getFieldNames().get(i)); topProjectExprs.add(RexInputRef.of(i, project.getRowType())); aggregate, belowProjectExprs, belowProjectColumnNames); RelNode newTopProjectRel = projectFactory.createProject( newProjectRel, topProjectExprs, project.getRowType().getFieldNames());
for (int i = resultSchema.size(); i < rt.getFieldCount(); i++) { if (collationInputRefs.contains(i)) { RexNode obyExpr = obChild.getChildExps().get(i); if (obyExpr instanceof RexCall) { LOG.debug("Old RexCall : " + obyExpr); .getChildExps().subList(0, resultSchema.size()), obChild.getRowType().getFieldNames() .subList(0, resultSchema.size())); obRel.replaceInput(0, replacementProjectRel);
gbInfo.outputColNames.addAll(aggRel.getRowType().getFieldNames()); for (int i : aggRel.getGroupSet()) { RexInputRef iRef = new RexInputRef(i, aggInputRel.getRowType().getFieldList() .get(i).getType()); tmpExprNodeDesc = iRef.accept(exprConv); gbInfo.gbKeys.add(tmpExprNodeDesc); gbInfo.gbKeyColNamesInInput.add(aggInputRel.getRowType().getFieldNames().get(i)); gbInfo.gbKeyTypes.add(tmpExprNodeDesc.getTypeInfo()); && (aggRel.getAggCallList().get(aggRel.getAggCallList().size() - 1).getAggregation() == HiveGroupingID.INSTANCE)) { gbInfo.grpIdFunctionNeeded = true;
Map<Integer, ColumnInfo> posToNonPartColInfo = ht.getNonPartColInfoMap(); List<Integer> neededColIndxsFrmReloptHT = scanRel.getNeededColIndxsFrmReloptHT(); List<String> scanColNames = scanRel.getRowType().getFieldNames(); String tableAlias = scanRel.getConcatQbIDAlias(); colName = scanColNames.get(index); if (VColsMap.containsKey(index)) { vc = VColsMap.get(index);
private static Pair<ImmutableList<Integer>, ImmutableSet<Integer>> buildColIndxsFrmReloptHT( RelOptHiveTable relOptHTable, RelDataType scanRowType) { RelDataType relOptHtRowtype = relOptHTable.getRowType(); ImmutableList<Integer> neededColIndxsFrmReloptHT; Builder<Integer> neededColIndxsFrmReloptHTBldr = new ImmutableList.Builder<Integer>(); ImmutableSet<Integer> viurtualOrPartColIndxsInTS; ImmutableSet.Builder<Integer> viurtualOrPartColIndxsInTSBldr = new ImmutableSet.Builder<Integer>(); Map<String, Integer> colNameToPosInReloptHT = HiveCalciteUtil .getRowColNameIndxMap(relOptHtRowtype.getFieldList()); List<String> colNamesInScanRowType = scanRowType.getFieldNames(); int partOrVirtualColStartPosInrelOptHtRowtype = relOptHTable.getNonPartColumns().size(); int tmp; for (int i = 0; i < colNamesInScanRowType.size(); i++) { tmp = colNameToPosInReloptHT.get(colNamesInScanRowType.get(i)); neededColIndxsFrmReloptHTBldr.add(tmp); if (tmp >= partOrVirtualColStartPosInrelOptHtRowtype) { viurtualOrPartColIndxsInTSBldr.add(i); } } neededColIndxsFrmReloptHT = neededColIndxsFrmReloptHTBldr.build(); viurtualOrPartColIndxsInTS = viurtualOrPartColIndxsInTSBldr.build(); return new Pair<ImmutableList<Integer>, ImmutableSet<Integer>>(neededColIndxsFrmReloptHT, viurtualOrPartColIndxsInTS); }
belowProjectExprs.add(project.getChildExps().get(i)); belowProjectColumnNames.add(project.getRowType().getFieldNames().get(i)); topProjectExprs.add(RexInputRef.of(i, project.getRowType())); aggregate, belowProjectExprs, belowProjectColumnNames); RelNode newTopProjectRel = projectFactory.createProject( newProjectRel, topProjectExprs, project.getRowType().getFieldNames());
/** 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()); } }