private HiveTableScan(RelOptCluster cluster, RelTraitSet traitSet, RelOptHiveTable table, String alias, String concatQbIDAlias, RelDataType newRowtype, boolean useQBIdInDigest, boolean insideView) { super(cluster, TraitsUtil.getDefaultTraitSet(cluster), table); assert getConvention() == HiveRelNode.CONVENTION; this.tblAlias = alias; this.concatQbIDAlias = concatQbIDAlias; this.hiveTableScanRowType = newRowtype; Pair<ImmutableList<Integer>, ImmutableSet<Integer>> colIndxPair = buildColIndxsFrmReloptHT(table, newRowtype); this.neededColIndxsFrmReloptHT = colIndxPair.getKey(); this.viurtualOrPartColIndxsInTS = colIndxPair.getValue(); this.useQBIdInDigest = useQBIdInDigest; this.insideView = insideView; }
public static RelNode renameTopLevelSelectInResultSchema(final RelNode rootRel, Pair<RelNode, RelNode> topSelparentPair, List<FieldSchema> resultSchema) throws CalciteSemanticException { RelNode parentOforiginalProjRel = topSelparentPair.getKey(); HiveProject originalProjRel = (HiveProject) topSelparentPair.getValue(); // Assumption: top portion of tree could only be // (limit)?(OB)?(Project).... List<RexNode> rootChildExps = originalProjRel.getChildExps(); if (resultSchema.size() != rootChildExps.size()) { // Safeguard against potential issues in CBO RowResolver construction. Disable CBO for now. LOG.error(PlanModifierUtil.generateInvalidSchemaMessage(originalProjRel, resultSchema, 0)); throw new CalciteSemanticException("Result Schema didn't match Optimized Op Tree Schema"); } List<String> newSelAliases = new ArrayList<String>(); String colAlias; for (int i = 0; i < rootChildExps.size(); i++) { colAlias = resultSchema.get(i).getName(); colAlias = getNewColAlias(newSelAliases, colAlias); newSelAliases.add(colAlias); } HiveProject replacementProjectRel = HiveProject.create(originalProjRel.getInput(), originalProjRel.getChildExps(), newSelAliases); if (rootRel == originalProjRel) { return replacementProjectRel; } else { parentOforiginalProjRel.replaceInput(0, replacementProjectRel); return rootRel; } }
public static RelNode renameTopLevelSelectInResultSchema(final RelNode rootRel, Pair<RelNode, RelNode> topSelparentPair, List<FieldSchema> resultSchema) throws CalciteSemanticException { RelNode parentOforiginalProjRel = topSelparentPair.getKey(); HiveProject originalProjRel = (HiveProject) topSelparentPair.getValue(); // Assumption: top portion of tree could only be // (limit)?(OB)?(Project).... List<RexNode> rootChildExps = originalProjRel.getChildExps(); if (resultSchema.size() != rootChildExps.size()) { // Safeguard against potential issues in CBO RowResolver construction. Disable CBO for now. LOG.error(PlanModifierUtil.generateInvalidSchemaMessage(originalProjRel, resultSchema, 0)); throw new CalciteSemanticException("Result Schema didn't match Optimized Op Tree Schema"); } List<String> newSelAliases = new ArrayList<String>(); String colAlias; for (int i = 0; i < rootChildExps.size(); i++) { colAlias = resultSchema.get(i).getName(); colAlias = getNewColAlias(newSelAliases, colAlias); newSelAliases.add(colAlias); } HiveProject replacementProjectRel = HiveProject.create(originalProjRel.getInput(), originalProjRel.getChildExps(), newSelAliases); if (rootRel == originalProjRel) { return replacementProjectRel; } else { parentOforiginalProjRel.replaceInput(0, replacementProjectRel); return rootRel; } }
Project obChild = (Project) topSelparentPair.getValue(); if (obChild.getRowType().getFieldCount() <= resultSchema.size()) { return;
SemanticAnalyzer.getColumnInternalName(projsForWindowSelOp.size()), wtp.getValue(), null, false); out_rwsch.putExpression(wExprSpec.getExpression(), oColInfo);
SemanticAnalyzer.getColumnInternalName(projsForWindowSelOp.size()), wtp.getValue(), null, false); out_rwsch.putExpression(wExprSpec.getExpression(), oColInfo);
return new OpAttr(inputOpAf.tabAlias, colInfoVColPair.getValue(), selOp);
Project obChild = (Project) topSelparentPair.getValue(); if (obChild.getRowType().getFieldCount() <= resultSchema.size()) { return;
return new OpAttr(inputOpAf.tabAlias, colInfoVColPair.getValue(), selOp);
RelNode topConstrainingProjArgsRel = obTopProjPair.getValue(); srcRel = (obRel == null) ? srcRel : obRel;
RowResolver selectOutputRR = selPair.getValue(); RelNode sortRel = null; RelNode returnRel = null; for (Pair<ASTNode, TypeInfo> astTypePair : vcASTTypePairs) { obSyntheticProjectRR.putExpression(astTypePair.getKey(), new ColumnInfo( SemanticAnalyzer.getColumnInternalName(vcolPos), astTypePair.getValue(), null, false)); vcolPos++;
for (Pair<ASTNode, TypeInfo> astTypePair : vcASTTypePairs) { obSyntheticProjectRR.putExpression(astTypePair.getKey(), new ColumnInfo( SemanticAnalyzer.getColumnInternalName(vcolPos), astTypePair.getValue(), null, false)); vcolPos++;
@Override public Pair<String, Long> getScrollAndTotalSizeThenSeekToHits() throws IOException { Pair<String, Long> scrollIdAndRecordCount = super.getScrollAndTotalSizeThenSeekToHits(); recordCount = scrollIdAndRecordCount.getValue(); return scrollIdAndRecordCount; }
@Override public Object extractValue(String column, int index){ Pair<RecordBatchData, Integer> dataBatch = find(index); Integer columnIndex = nameToColumnIndex.get(column); return dataBatch.getKey().getVectors().get(columnIndex).getObject(dataBatch.getValue()); }
public static ConvertedRelNode validateAndConvert(SqlHandlerConfig config, SqlNode sqlNode, RelTransformer relTransformer) throws ForemanSetupException, RelConversionException, ValidationException { final Pair<SqlNode, RelDataType> validatedTypedSqlNode = validateNode(config, sqlNode); final SqlNode validated = validatedTypedSqlNode.getKey(); final RelNode rel = convertToRel(config, validated, relTransformer); final RelNode preprocessedRel = preprocessNode(config, rel); return new ConvertedRelNode(preprocessedRel, validatedTypedSqlNode.getValue()); }
private HoldingContainer getHoldingContainer(ClassGenerator<?> generator, MajorType majorType, Function<DrillBuf, ? extends ValueHolder> function) { JType holderType = generator.getHolderType(majorType); Pair<Integer, JVar> depthVar = generator.declareClassConstField("const", holderType, function); JFieldRef outputSet = null; JVar var = depthVar.getValue(); if (majorType.getMode() == TypeProtos.DataMode.OPTIONAL) { outputSet = var.ref("isSet"); } return new HoldingContainer(majorType, var, var.ref("value"), outputSet); }
@Override public DataType extractType(String column, int index){ Pair<RecordBatchData, Integer> dataBatch = find(index); Column columnDef = getColumn(column); ValueVector vv = dataBatch.getKey().getVectors().get(columnDef.getIndex()); if (columnDef.getType() == DataType.MIXED) { final int typeValue = ((UnionVector)vv).getTypeValue(dataBatch.getValue()); return DataTypeUtil.getDataType(getMinorTypeFromArrowMinorType(MinorType.values()[typeValue])); } return columnDef.getType(); }