예제 #1
0
 /** Creates a DrillScan. */
 public DrillScanRel(
     final RelOptCluster cluster, final RelTraitSet traits, final RelOptTable table) {
   // By default, scan does not support project pushdown.
   // Decision whether push projects into scan will be made solely in DrillPushProjIntoScanRule.
   this(cluster, traits, table, table.getRowType(), GroupScan.ALL_COLUMNS);
   this.settings = PrelUtil.getPlannerSettings(cluster.getPlanner());
 }
예제 #2
0
  @Override
  public RelNode toRel(ToRelContext context, RelOptTable relOptTable) {
    ViewExpansionContext.ViewExpansionToken token = null;
    try {
      RelDataType rowType = relOptTable.getRowType();
      RelNode rel;

      if (viewExpansionContext.isImpersonationEnabled()) {
        token = viewExpansionContext.reserveViewExpansionToken(viewOwner);
        rel =
            context.expandView(
                rowType, view.getSql(), token.getSchemaTree(), view.getWorkspaceSchemaPath());
      } else {
        rel = context.expandView(rowType, view.getSql(), view.getWorkspaceSchemaPath());
      }

      // If the View's field list is not "*", create a cast.
      if (!view.isDynamic() && !view.hasStar()) {
        rel = RelOptUtil.createCastRel(rel, rowType, true);
      }

      return rel;
    } finally {
      if (token != null) {
        token.release();
      }
    }
  }
예제 #3
0
 public JdbcTableModify(
     RelOptCluster cluster,
     RelTraitSet traitSet,
     RelOptTable table,
     Prepare.CatalogReader catalogReader,
     RelNode input,
     Operation operation,
     List<String> updateColumnList,
     boolean flattened) {
   super(cluster, traitSet, table, catalogReader, input, operation, updateColumnList, flattened);
   assert input.getConvention() instanceof JdbcConvention;
   assert getConvention() instanceof JdbcConvention;
   final ModifiableTable modifiableTable = table.unwrap(ModifiableTable.class);
   if (modifiableTable == null) {
     throw new AssertionError(); // TODO: user error in validator
   }
   this.expression = table.getExpression(Queryable.class);
   if (expression == null) {
     throw new AssertionError(); // TODO: user error in validator
   }
 }
예제 #4
0
 /**
  * Converts a {@link SqlValidatorScope} into a {@link RelOptTable}. This is only possible if the
  * scope represents an identifier, such as "sales.emp". Otherwise, returns null.
  *
  * @param namespace Namespace
  * @param catalogReader Schema
  * @param datasetName Name of sample dataset to substitute, or null to use the regular table
  * @param usedDataset Output parameter which is set to true if a sample dataset is found; may be
  *     null
  */
 public static RelOptTable getRelOptTable(
     SqlValidatorNamespace namespace,
     Prepare.CatalogReader catalogReader,
     String datasetName,
     boolean[] usedDataset) {
   if (!namespace.isWrapperFor(TableNamespace.class)) {
     return null;
   }
   final TableNamespace tableNamespace = namespace.unwrap(TableNamespace.class);
   final List<String> names = tableNamespace.getTable().getQualifiedName();
   RelOptTable table;
   if (datasetName != null && catalogReader instanceof RelOptSchemaWithSampling) {
     final RelOptSchemaWithSampling reader = (RelOptSchemaWithSampling) catalogReader;
     table = reader.getTableForMember(names, datasetName, usedDataset);
   } else {
     // Schema does not support substitution. Ignore the data set, if any.
     table = catalogReader.getTableForMember(names);
   }
   if (!tableNamespace.extendedFields.isEmpty()) {
     table = table.extend(tableNamespace.extendedFields);
   }
   return table;
 }