@Override public void onMatch(final RelOptRuleCall call) { final LogicalTableScan scan = call.rel(0); final RelOptTable table = scan.getTable(); final DruidTable druidTable = table.unwrap(DruidTable.class); if (druidTable != null) { call.transformTo( DruidQueryRel.fullScan(scan, table, druidTable, queryMaker) ); } } }
@Override public RelNode convert(RelNode rel) { final TableScan scan = (TableScan) rel; int parallelismHint = DEFAULT_PARALLELISM_HINT; final ParallelTable parallelTable = scan.getTable().unwrap(ParallelTable.class); if (parallelTable != null && parallelTable.parallelismHint() != null) { parallelismHint = parallelTable.parallelismHint(); } final Table table = scan.getTable().unwrap(Table.class); switch (table.getJdbcTableType()) { case STREAM: return new StreamsStreamScanRel(scan.getCluster(), scan.getTraitSet().replace(StreamsLogicalConvention.INSTANCE), scan.getTable(), parallelismHint); default: throw new IllegalArgumentException(String.format("Unsupported table type: %s", table.getJdbcTableType())); } } }
StormTable stormTable = tableModify.getTable().unwrap(StormTable.class); if (stormTable != null) { primaryKey = stormTable.primaryKey(); } else { StormStreamableTable streamableTable = tableModify.getTable().unwrap(StormStreamableTable.class); if (streamableTable != null) { primaryKey = streamableTable.primaryKey(); final Table table = tableModify.getTable().unwrap(Table.class);
public void validateUpdate(SqlUpdate call) { final SqlValidatorNamespace targetNamespace = getNamespace(call); validateNamespace(targetNamespace, unknownType); final RelOptTable relOptTable = SqlValidatorUtil.getRelOptTable( targetNamespace, catalogReader.unwrap(Prepare.CatalogReader.class), null, null); final SqlValidatorTable table = relOptTable == null ? targetNamespace.getTable() : relOptTable.unwrap(SqlValidatorTable.class); final RelDataType targetRowType = createTargetRowType( table, call.getTargetColumnList(), true); final SqlSelect select = call.getSourceSelect(); validateSelect(select, targetRowType); final RelDataType sourceRowType = getNamespace(call).getRowType(); checkTypeAssignment(sourceRowType, targetRowType, call); checkConstraint(table, call, targetRowType); validateAccess(call.getTargetTable(), table, SqlAccessEnum.UPDATE); }
final SqlValidatorTable table = relOptTable == null ? targetNamespace.getTable() : relOptTable.unwrap(SqlValidatorTable.class);
public void materialize(RelNode queryRel, RelOptTable starRelOptTable) { this.queryRel = queryRel; this.starRelOptTable = starRelOptTable; assert starRelOptTable.unwrap(StarTable.class) != null; } }
public void materialize(RelNode queryRel, RelOptTable starRelOptTable) { this.queryRel = queryRel; this.starRelOptTable = starRelOptTable; assert starRelOptTable.unwrap(StarTable.class) != null; } }
@Override public <T> T unwrap(Class<T> clazz) { return relOptTable.unwrap(clazz); }
protected static boolean test(TableScan scan) { // We can only push projects into a ProjectableFilterableTable. final RelOptTable table = scan.getTable(); return table.unwrap(ProjectableFilterableTable.class) != null; }
public StarTable createStarTable() { final List<Table> tables = new ArrayList<>(); for (LatticeNode node : rootNode.descendants) { tables.add(node.table.t.unwrap(Table.class)); } return StarTable.of(this, tables); }
public static JavaRowFormat deduceFormat(RelOptTable table) { final Class elementType = deduceElementType(table.unwrap(Table.class)); return elementType == Object[].class ? JavaRowFormat.ARRAY : JavaRowFormat.CUSTOM; }
protected static boolean test(TableScan scan) { // We can only push projects into a ProjectableFilterableTable. final RelOptTable table = scan.getTable(); return table.unwrap(ProjectableFilterableTable.class) != null; }
public static JavaRowFormat deduceFormat(RelOptTable table) { final Class elementType = deduceElementType(table.unwrap(Table.class)); return elementType == Object[].class ? JavaRowFormat.ARRAY : JavaRowFormat.CUSTOM; }
public StarTable createStarTable() { final List<Table> tables = new ArrayList<>(); for (Node node : nodes) { tables.add(node.scan.getTable().unwrap(Table.class)); } return StarTable.of(this, tables); }
public <T> T unwrap(Class<T> clazz) { if (clazz.isInstance(this)) { return clazz.cast(this); } return parent.unwrap(clazz); }
@Override public RelNode visit(TableScan scan) { final RelOptTable table = scan.getTable(); final TranslatableTable translatableTable = table.unwrap(TranslatableTable.class); if (translatableTable != null) { return translatableTable.toRel(context, table); } return super.visit(scan); } });
private PlannerOp planEnumerableTableScan(EnumerableTableScan scan, RelDataType rowType) { final String tableSpace = scan.getTable().getQualifiedName().get(0); final TableImpl tableImpl = (TableImpl) scan.getTable().unwrap(org.apache.calcite.schema.Table.class ); Table table = tableImpl.tableManager.getTable(); ScanStatement scanStatement = new ScanStatement(tableSpace, table, null); return new TableScanOp(scanStatement); }
@Override public void onMatch(RelOptRuleCall call) { final Delta delta = call.rel(0); final TableScan scan = call.rel(1); final RelOptTable relOptTable = scan.getTable(); final StreamableTable streamableTable = relOptTable.unwrap(StreamableTable.class); final RelBuilder builder = call.builder(); if (streamableTable == null) { call.transformTo(builder.values(delta.getRowType()).build()); } } }