Java Code Examples for org.apache.calcite.plan.RelOptTable#ToRelContext

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: JdbcTableUtils.java    From calcite-sql-rewriter with Apache License 2.0 6 votes vote down vote up
static RelNode toRel(RelOptCluster cluster, RelOptSchema relOptSchema, JdbcTable table, List<String> qualifiedName) {
	RelOptTable.ToRelContext toRelContext = new RelOptTable.ToRelContext() {
		@Override
		public RelOptCluster getCluster() {
			return cluster;
		}

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

	return table.toRel(
			toRelContext,
			relOptSchema.getTableForMember(qualifiedName)
	);
}
 
Example 2
Source File: GremlinTable.java    From sql-gremlin with Apache License 2.0 5 votes vote down vote up
public RelNode toRel(
        RelOptTable.ToRelContext context,
        RelOptTable relOptTable) {
    final RelOptCluster cluster = context.getCluster();
    int fieldCount = tableDef.columns.size();
    int[] fields = new int[fieldCount];
    for(int i = 0;i < fieldCount; i++) {
        fields[i] = i;
    }
    return new GremlinTableScan(cluster, cluster.traitSetOf(GremlinRel.CONVENTION),
            relOptTable, this, fields);
}
 
Example 3
Source File: DruidTable.java    From calcite with Apache License 2.0 5 votes vote down vote up
public RelNode toRel(RelOptTable.ToRelContext context,
    RelOptTable relOptTable) {
  final RelOptCluster cluster = context.getCluster();
  final TableScan scan = LogicalTableScan.create(cluster, relOptTable, ImmutableList.of());
  return DruidQuery.create(cluster,
      cluster.traitSetOf(BindableConvention.INSTANCE), relOptTable, this,
      ImmutableList.of(scan));
}
 
Example 4
Source File: ProvenanceTable.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public RelNode toRel(final RelOptTable.ToRelContext context, final RelOptTable relOptTable) {
    // Request all fields.
    final int fieldCount = relOptTable.getRowType().getFieldCount();
    final int[] fields = new int[fieldCount];
    for (int i = 0; i < fieldCount; i++) {
        fields[i] = i;
    }

    return new ProvenanceTableScan(context.getCluster(), relOptTable, this, fields);
}
 
Example 5
Source File: ProcessGroupStatusTable.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public RelNode toRel(final RelOptTable.ToRelContext context, final RelOptTable relOptTable) {
    // Request all fields.
    final int fieldCount = relOptTable.getRowType().getFieldCount();
    final int[] fields = new int[fieldCount];
    for (int i = 0; i < fieldCount; i++) {
        fields[i] = i;
    }

    return new ProcessGroupStatusTableScan(context.getCluster(), relOptTable, this, fields);
}
 
Example 6
Source File: QueryOperationCatalogViewTable.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public RelNode convertToRel(RelOptTable.ToRelContext context) {
	FlinkRelBuilder relBuilder = FlinkRelBuilder.of(
			context,
			context.getCluster(),
			this.getRelOptSchema());

	return relBuilder.queryOperation(catalogView.getQueryOperation()).build();
}
 
Example 7
Source File: LixToRelTranslator.java    From calcite with Apache License 2.0 5 votes vote down vote up
RelOptTable.ToRelContext toRelContext() {
  if (preparingStmt instanceof RelOptTable.ViewExpander) {
    final RelOptTable.ViewExpander viewExpander =
        (RelOptTable.ViewExpander) this.preparingStmt;
    return ViewExpanders.toRelContext(viewExpander, cluster);
  } else {
    return ViewExpanders.simpleContext(cluster);
  }
}
 
Example 8
Source File: ProcessorStatusTable.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public RelNode toRel(final RelOptTable.ToRelContext context, final RelOptTable relOptTable) {
    // Request all fields.
    final int fieldCount = relOptTable.getRowType().getFieldCount();
    final int[] fields = new int[fieldCount];
    for (int i = 0; i < fieldCount; i++) {
        fields[i] = i;
    }

    return new ProcessorStatusTableScan(context.getCluster(), relOptTable, this, fields);
}
 
Example 9
Source File: SplunkTable.java    From calcite with Apache License 2.0 5 votes vote down vote up
public RelNode toRel(
    RelOptTable.ToRelContext context,
    RelOptTable relOptTable) {
  return new SplunkTableScan(
      context.getCluster(),
      relOptTable,
      this,
      "search",
      null,
      null,
      relOptTable.getRowType().getFieldNames());
}
 
Example 10
Source File: RelFactories.java    From Bats with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a {@link TableScanFactory} that uses a
 * {@link org.apache.calcite.plan.RelOptTable.ViewExpander} to handle
 * {@link TranslatableTable} instances, and falls back to a default
 * factory for other tables.
 *
 * @param viewExpander View expander
 * @param tableScanFactory Factory for non-translatable tables
 * @return Table scan factory
 */
public static TableScanFactory expandingScanFactory(
    RelOptTable.ViewExpander viewExpander,
    TableScanFactory tableScanFactory) {
  return (cluster, table) -> {
    final TranslatableTable translatableTable =
        table.unwrap(TranslatableTable.class);
    if (translatableTable != null) {
      final RelOptTable.ToRelContext toRelContext =
          ViewExpanders.toRelContext(viewExpander, cluster);
      return translatableTable.toRel(toRelContext, table);
    }
    return tableScanFactory.createScan(cluster, table);
  };
}
 
Example 11
Source File: QueryOperationCatalogViewTable.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public RelNode toRel(RelOptTable.ToRelContext context, RelOptTable relOptTable) {
	FlinkRelBuilder relBuilder = FlinkRelBuilder.of(context.getCluster(), relOptTable.getRelOptSchema());

	RelNode relNode = relBuilder.tableOperation(catalogView.getQueryOperation()).build();
	return RelOptUtil.createCastRel(relNode, rowType.apply(relBuilder.getTypeFactory()), false);
}
 
Example 12
Source File: RelFactories.java    From calcite with Apache License 2.0 4 votes vote down vote up
public RelNode createScan(RelOptTable.ToRelContext toRelContext, RelOptTable table) {
  return table.toRel(toRelContext);
}
 
Example 13
Source File: QuarkViewTable.java    From quark with Apache License 2.0 4 votes vote down vote up
public RelNode toRel(
    RelOptTable.ToRelContext context,
    RelOptTable relOptTable) {
  return new QuarkViewScan(context.getCluster(), this.backUpRelOptTable, this);
}
 
Example 14
Source File: MycatPhysicalTable.java    From Mycat2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public RelNode toRel(RelOptTable.ToRelContext context, RelOptTable relOptTable) {
    return LogicalTableScan.create(context.getCluster(), relOptTable, ImmutableList.of());
}
 
Example 15
Source File: JdbcTable.java    From calcite with Apache License 2.0 4 votes vote down vote up
public RelNode toRel(RelOptTable.ToRelContext context,
    RelOptTable relOptTable) {
  return new JdbcTableScan(context.getCluster(), relOptTable, this,
      jdbcSchema.convention);
}
 
Example 16
Source File: MockCatalogReader.java    From calcite with Apache License 2.0 4 votes vote down vote up
@Override public RelNode toRel(RelOptTable.ToRelContext context, RelOptTable relOptTable) {
  return LogicalTableScan.create(context.getCluster(), relOptTable, context.getTableHints());
}
 
Example 17
Source File: ElasticsearchTable.java    From calcite with Apache License 2.0 4 votes vote down vote up
@Override public RelNode toRel(RelOptTable.ToRelContext context, RelOptTable relOptTable) {
  final RelOptCluster cluster = context.getCluster();
  return new ElasticsearchTableScan(cluster, cluster.traitSetOf(ElasticsearchRel.CONVENTION),
      relOptTable, this, null);
}
 
Example 18
Source File: EnumerableRelFactories.java    From calcite with Apache License 2.0 4 votes vote down vote up
public RelNode createScan(RelOptTable.ToRelContext toRelContext, RelOptTable table) {
  return EnumerableTableScan.create(toRelContext.getCluster(), table);
}
 
Example 19
Source File: TranslatableTable.java    From Bats with Apache License 2.0 4 votes vote down vote up
/** Converts this table into a {@link RelNode relational expression}. */
RelNode toRel(
    RelOptTable.ToRelContext context,
    RelOptTable relOptTable);
 
Example 20
Source File: StarTable.java    From calcite with Apache License 2.0 4 votes vote down vote up
public RelNode toRel(RelOptTable.ToRelContext context, RelOptTable table) {
  // Create a table scan of infinite cost.
  return new StarTableScan(context.getCluster(), table);
}