private RexNode convertCastForFIdx(RexCall condition, IndexDescriptor index, IndexCallContext context, RelNode origScan) { if (index == null) { return condition; } FunctionalIndexInfo functionInfo = index.getFunctionalInfo(); if (!functionInfo.hasFunctional()) { return condition; } // The functional index has a different row-type than the original scan. Use the index row-type when // converting the condition RelDataType newRowType = FunctionalIndexHelper.rewriteFunctionalRowType(origScan, context, functionInfo); RexBuilder builder = origScan.getCluster().getRexBuilder(); return FunctionalIndexHelper.convertConditionForIndexScan(condition, origScan, newRowType, builder, functionInfo); }
/** * This function computes statistics when there is no query condition * @param jTabGrpScan - The current group scan * @param indexes - The collection of indexes to use for getting statistics * @param scanRel - The current scanRel * @param context - The index plan call context */ private void populateStatsForNoFilter(JsonTableGroupScan jTabGrpScan, IndexCollection indexes, RelNode scanRel, IndexCallContext context) { // Get the stats payload for full table (has total rows in the table) StatisticsPayload ftsPayload = jTabGrpScan.getFirstKeyEstimatedStats(null, null, scanRel); addToCache(null, null, context, ftsPayload, jTabGrpScan, scanRel, scanRel.getRowType()); addToCache(null, jTabGrpScan.getAverageRowSizeStats(null), ftsPayload); // Get the stats for all indexes for (IndexDescriptor idx: indexes) { StatisticsPayload idxPayload = jTabGrpScan.getFirstKeyEstimatedStats(null, idx, scanRel); StatisticsPayload idxRowSizePayload = jTabGrpScan.getAverageRowSizeStats(idx); RelDataType newRowType; FunctionalIndexInfo functionInfo = idx.getFunctionalInfo(); if (functionInfo.hasFunctional()) { newRowType = FunctionalIndexHelper.rewriteFunctionalRowType(scanRel, context, functionInfo); } else { newRowType = scanRel.getRowType(); } addToCache(null, idx, context, idxPayload, jTabGrpScan, scanRel, newRowType); addToCache(idx, idxRowSizePayload, ftsPayload); } }
RelDataType newRowType; FunctionalIndexInfo functionInfo = idx.getFunctionalInfo(); if (functionInfo.hasFunctional()) { newRowType = FunctionalIndexHelper.rewriteFunctionalRowType(scanRel, context, functionInfo); } else { FunctionalIndexInfo functionInfo = idx.getFunctionalInfo(); RelDataType newRowType = scanRel.getRowType(); if (functionInfo.hasFunctional()) { newRowType = FunctionalIndexHelper.rewriteFunctionalRowType(scanRel, context, functionInfo);
/** * * @param inputIndex * @param functionInfo functional index information that may impact rewrite * @return */ private RexNode rewriteFunctionalCondition(RexNode inputIndex, RelDataType newRowType, FunctionalIndexInfo functionInfo) { if (!functionInfo.hasFunctional()) { return inputIndex; } return FunctionalIndexHelper.convertConditionForIndexScan(inputIndex, origScan, newRowType, builder, functionInfo); }
FunctionalIndexInfo functionInfo, List<SchemaPath> addedPaths) { if (!functionInfo.hasFunctional()) { return paths;
/** * For a particular table scan for table T1 and an index on that table, find out if it is a covering index * @return */ static public boolean isCoveringIndex(IndexCallContext indexContext, FunctionalIndexInfo functionInfo) { if (functionInfo.hasFunctional()) { // need info from full query return queryCoveredByIndex(indexContext, functionInfo); } DbGroupScan groupScan = (DbGroupScan) getGroupScan(indexContext.getScan()); List<LogicalExpression> tableCols = Lists.newArrayList(); tableCols.addAll(groupScan.getColumns()); return functionInfo.getIndexDesc().isCoveringIndex(tableCols); }
private RexNode convertCastForFIdx(RexCall condition, IndexDescriptor index, IndexCallContext context, RelNode origScan) { if (index == null) { return condition; } FunctionalIndexInfo functionInfo = index.getFunctionalInfo(); if (!functionInfo.hasFunctional()) { return condition; } // The functional index has a different row-type than the original scan. Use the index row-type when // converting the condition RelDataType newRowType = FunctionalIndexHelper.rewriteFunctionalRowType(origScan, context, functionInfo); RexBuilder builder = origScan.getCluster().getRexBuilder(); return FunctionalIndexHelper.convertConditionForIndexScan(condition, origScan, newRowType, builder, functionInfo); }
if (!indexInfo.hasFunctional()) { for (int projectExprIdx = 0; projectExprIdx < projectRexs.size(); projectExprIdx++) { RexNode n = projectRexs.get(projectExprIdx);
if (!indexInfo.hasFunctional()) { Map<LogicalExpression, Integer> projectExprs = Maps.newLinkedHashMap(); DrillParseContext parserContext = new DrillParseContext(PrelUtil.getPlannerSettings(input.getCluster()));
RelDataType newRowType, FunctionalIndexInfo functionInfo) { if (!functionInfo.hasFunctional()) { return toRewriteRex;
FunctionalIndexInfo functionInfo, Collection<SchemaPath> addedPaths) { RelDataType origRowType = origScan.getRowType(); if (!functionInfo.hasFunctional()) { return origRowType;
/** * This function computes statistics when there is no query condition * @param jTabGrpScan - The current group scan * @param indexes - The collection of indexes to use for getting statistics * @param scanRel - The current scanRel * @param context - The index plan call context */ private void populateStatsForNoFilter(JsonTableGroupScan jTabGrpScan, IndexCollection indexes, RelNode scanRel, IndexCallContext context) { // Get the stats payload for full table (has total rows in the table) StatisticsPayload ftsPayload = jTabGrpScan.getFirstKeyEstimatedStats(null, null, scanRel); addToCache(null, null, context, ftsPayload, jTabGrpScan, scanRel, scanRel.getRowType()); addToCache(null, jTabGrpScan.getAverageRowSizeStats(null), ftsPayload); // Get the stats for all indexes for (IndexDescriptor idx: indexes) { StatisticsPayload idxPayload = jTabGrpScan.getFirstKeyEstimatedStats(null, idx, scanRel); StatisticsPayload idxRowSizePayload = jTabGrpScan.getAverageRowSizeStats(idx); RelDataType newRowType; FunctionalIndexInfo functionInfo = idx.getFunctionalInfo(); if (functionInfo.hasFunctional()) { newRowType = FunctionalIndexHelper.rewriteFunctionalRowType(scanRel, context, functionInfo); } else { newRowType = scanRel.getRowType(); } addToCache(null, idx, context, idxPayload, jTabGrpScan, scanRel, newRowType); addToCache(idx, idxRowSizePayload, ftsPayload); } }
RelDataType newRowType; FunctionalIndexInfo functionInfo = idx.getFunctionalInfo(); if (functionInfo.hasFunctional()) { newRowType = FunctionalIndexHelper.rewriteFunctionalRowType(scanRel, context, functionInfo); } else { FunctionalIndexInfo functionInfo = idx.getFunctionalInfo(); RelDataType newRowType = scanRel.getRowType(); if (functionInfo.hasFunctional()) { newRowType = FunctionalIndexHelper.rewriteFunctionalRowType(scanRel, context, functionInfo);
indexScanPrel, indexContext.getLowerProject().getProjects(), indexContext.getLowerProject().getRowType()); if (functionInfo.hasFunctional()) {
finalRel, IndexPlanUtils.getProjects(upperProject), upperProject.getRowType()); if (functionInfo.hasFunctional()) {