... if (planContract.hasQueryContextInfo()) { // Conduct input column projection // This shows an example where input columns needed are // the output columns projected. // This is specified in the completePlanningContract method. List<ColumnDefinition> inputColumnsNeeded = new ArrayList<ColumnDefinition>(); // add the output columns projected to the input column projection List<ColumnDefinition> outputColumnsToProject = qci.getOutputColumnsToProject(); // The planner expects inputColumnsNeeded only when there are // output columns to project. // Add a new column from the input that is not in the output // column projection. if (!outputColumnsToProject.isEmpty()) { inputColumnsNeeded = getInputColNotInOutputProjection(outputColumnsToProject); } String inputColNameNeeded=null; if (!inputColumnsNeeded.isEmpty()) { inputColNameNeeded = inputColumnsNeeded.get(0).getColumnName(); } HashSet<String> columnNamesAdded = new HashSet<String>(); for (ColumnDefinition colDef: outputColumnsToProject) { assert (colDef != null); // If projection contains column names // "id", and "number_md5sum", // the columns needed would be "id" and "number" String columnName; if (colDef.getColumnName().endsWith(md5sumSuffix_)) { columnName = colDef.getColumnName().split(md5sumSuffix_)[0]; } else { columnName = colDef.getColumnName(); } if (!columnName.equals(inputColNameNeeded) && !columnNamesAdded.contains(columnName)) { Integer inputColIndex = runtimeSchema_.getRuntimeInputIndex(columnName); assert inputColIndex != null; ColumnDefinition inputColumn = runtimeSchema_.getInputCols().get(inputColIndex); inputColumnsNeeded.add(inputColumn); columnNamesAdded.add(columnName); } } ... InputContext inputContext = new InputContext.Builder() ... .setInputColumnsNeeded(inputColumnsNeeded) ...
For full context, see Examples.