org.apache.calcite.plan.RelOptTable.ToRelContext Java Examples

The following examples show how to use org.apache.calcite.plan.RelOptTable.ToRelContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DrillViewTable.java    From Bats with Apache License 2.0 6 votes vote down vote up
@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 = expandViewForImpersonatedUser(context, rowType, view.getWorkspaceSchemaPath(), token.getSchemaTree());
    } else {
      rel = context.expandView(rowType, view.getSql(), view.getWorkspaceSchemaPath(), ImmutableList.<String>of()).rel;
    }

    // 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();
    }
  }
}
 
Example #2
Source File: MaterializationExpander.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
private RelNode expandSchemaPath(final List<String> path) {
  final DremioCatalogReader catalog = parent.getCatalogReader();
  final RelOptTable table = catalog.getTable(path);
  if(table == null){
    return null;
  }

  ToRelContext context = new ToRelContext() {
    @Override
    public RelOptCluster getCluster() {
      return parent.getCluster();
    }

    @Override
    public RelRoot expandView(RelDataType rowType, String queryString, List<String> schemaPath,
                              List<String> viewPath) {
      return null;
    }
  };

  NamespaceTable newTable = table.unwrap(NamespaceTable.class);
  if(newTable != null){
    return newTable.toRel(context, table);
  }

  throw new IllegalStateException("Unable to expand path for table: " + table);
}
 
Example #3
Source File: DrillTranslatableTable.java    From Bats with Apache License 2.0 4 votes vote down vote up
@Override
public RelNode toRel(ToRelContext context, RelOptTable table) {
  return drillTable.toRel(context, table);
}
 
Example #4
Source File: DrillViewTable.java    From Bats with Apache License 2.0 4 votes vote down vote up
protected RelNode expandViewForImpersonatedUser(ToRelContext context,
                                                RelDataType rowType,
                                                List<String> workspaceSchemaPath,
                                                SchemaPlus tokenSchemaTree) {
  return context.expandView(rowType, view.getSql(), tokenSchemaTree, workspaceSchemaPath).rel;
}
 
Example #5
Source File: OLAPTable.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@Override
public RelNode toRel(ToRelContext context, RelOptTable relOptTable) {
    int fieldCount = relOptTable.getRowType().getFieldCount();
    int[] fields = identityList(fieldCount);
    return new OLAPTableScan(context.getCluster(), relOptTable, this, fields);
}
 
Example #6
Source File: ViewTable.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
@Override
public RelNode toRel(ToRelContext context, RelOptTable relOptTable) {
  return ((ExtendedToRelContext) context).expandView(this).rel;
}
 
Example #7
Source File: DremioSqlToRelConverter.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
public ToRelContext createToRelContext() {
  return new ExtendedToRelContext(sqlConverter);
}
 
Example #8
Source File: NamespaceTable.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
@Override
public ScanCrel toRel(ToRelContext toRelContext, RelOptTable relOptTable) {
  return new ScanCrel(toRelContext.getCluster(), toRelContext.getCluster().traitSetOf(Convention.NONE), dataset.getStoragePluginId(), dataset, null, 1.0d, true);
}
 
Example #9
Source File: OLAPTable.java    From kylin with Apache License 2.0 4 votes vote down vote up
@Override
public RelNode toRel(ToRelContext context, RelOptTable relOptTable) {
    int fieldCount = relOptTable.getRowType().getFieldCount();
    int[] fields = identityList(fieldCount);
    return new OLAPTableScan(context.getCluster(), relOptTable, this, fields);
}
 
Example #10
Source File: PigTable.java    From calcite with Apache License 2.0 4 votes vote down vote up
@Override public RelNode toRel(ToRelContext context, RelOptTable relOptTable) {
  final RelOptCluster cluster = context.getCluster();
  return new PigTableScan(cluster, cluster.traitSetOf(PigRel.CONVENTION), relOptTable);
}