CalciteSchema viewSchema = calciteCatalogReader.getTable(tableName) .unwrap(CalciteSchema.class); assert viewSchema != null; CalciteSchema.TableEntry viewTEntry = viewSchema.getTable(
private static List<RelCollation> deduceMonotonicity( Prepare.PreparingTable table) { final List<RelCollation> collationList = new ArrayList<>(); // Deduce which fields the table is sorted on. int i = -1; for (RelDataTypeField field : table.getRowType().getFieldList()) { ++i; final SqlMonotonicity monotonicity = table.getMonotonicity(field.getName()); if (monotonicity != SqlMonotonicity.NOT_MONOTONIC) { final RelFieldCollation.Direction direction = monotonicity.isDecreasing() ? RelFieldCollation.Direction.DESCENDING : RelFieldCollation.Direction.ASCENDING; collationList.add( RelCollations.of( new RelFieldCollation(i, direction))); } } return collationList; }
.unwrap(CalciteSchema.class); assert tileSchema != null; CalciteSchema.TableEntry tileTEntry = tileSchema.getTable(
SqlValidatorTable validatorTable = ns.getTable(); if (validatorTable instanceof Prepare.PreparingTable) { Table t = ((Prepare.PreparingTable) validatorTable).unwrap(Table.class); if (t instanceof CustomColumnResolvingTable) { final List<Pair<RelDataTypeField, List<String>>> entries =
SqlValidatorTable validatorTable = ns.getTable(); if (validatorTable instanceof Prepare.PreparingTable) { Table t = ((Prepare.PreparingTable) validatorTable).unwrap(Table.class); if (t instanceof CustomColumnResolvingTable) { final List<Pair<RelDataTypeField, List<String>>> entries =
/** * If schema is not indicated (only one element in the list) or schema is default temporary workspace, * we need to check among session temporary tables in default temporary workspace first. * If temporary table is found and temporary tables usage is allowed, its table instance will be returned, * otherwise search will be conducted in original workspace. * * @param names list of schema and table names, table name is always the last element * @return table instance, null otherwise * @throws UserException if temporary tables usage is disallowed */ @Override public Prepare.PreparingTable getTable(final List<String> names) { String originalTableName = session.getOriginalTableNameFromTemporaryTable(names.get(names.size() - 1)); if (originalTableName != null) { if (!allowTemporaryTables) { throw UserException .validationError() .message("Temporary tables usage is disallowed. Used temporary table name: [%s].", originalTableName) .build(logger); } } Prepare.PreparingTable table = super.getTable(names); DrillTable unwrap; // add session options if found table is Drill table if (table != null && (unwrap = table.unwrap(DrillTable.class)) != null) { unwrap.setOptions(session.getOptions()); } return table; }
@Override public Table createTable(CalciteSchema schema, String viewSql, List<String> viewSchemaPath) { assert nzTile.tableName != null; CalciteCatalogReader calciteCatalogReader = new CalciteCatalogReader( schema.root(), false, queryContext.getDefaultSchemaPath(), queryContext.getTypeFactory()); CalciteSchema tileSchema = calciteCatalogReader.getTable(nzTile.tableName) .unwrap(CalciteSchema.class); assert tileSchema != null; CalciteSchema.TableEntry tileTEntry = tileSchema.getTable( Util.last(nzTile.tableName), false); assert tileTEntry != null; return new QuarkTileTable(nzTile, calciteCatalogReader, tileTEntry.getTable().getRowType(queryContext.getTypeFactory()), Schemas.path(rootSchema, nzTile.alias), (QuarkTable) tileTEntry.getTable()); } };
private static List<RelCollation> deduceMonotonicity( Prepare.PreparingTable table) { final List<RelCollation> collationList = new ArrayList<>(); // Deduce which fields the table is sorted on. int i = -1; for (RelDataTypeField field : table.getRowType().getFieldList()) { ++i; final SqlMonotonicity monotonicity = table.getMonotonicity(field.getName()); if (monotonicity != SqlMonotonicity.NOT_MONOTONIC) { final RelFieldCollation.Direction direction = monotonicity.isDecreasing() ? RelFieldCollation.Direction.DESCENDING : RelFieldCollation.Direction.ASCENDING; collationList.add( RelCollations.of( new RelFieldCollation(i, direction))); } } return collationList; }
@Override public Prepare.PreparingTable getTable(List<String> names) { Prepare.PreparingTable originRelOptTable = super.getTable(names); if (originRelOptTable == null) { return null; } else { // Wrap FlinkTable as FlinkRelOptTable to use in query optimization. FlinkTable table = originRelOptTable.unwrap(FlinkTable.class); if (table != null) { return FlinkRelOptTable.create( originRelOptTable.getRelOptSchema(), originRelOptTable.getRowType(), originRelOptTable.getQualifiedName(), table); } else { return originRelOptTable; } } } }
private void visitQuarkTileScan(QuarkTileScan node) { foundOptimizedTableScan.set(true); QuarkTile quarkTile = node.getQuarkTile(); CalciteCatalogReader calciteCatalogReader = new CalciteCatalogReader( CalciteSchema.from(getRootSchma()), false, context.getDefaultSchemaPath(), getTypeFactory()); CalciteSchema tileSchema = calciteCatalogReader.getTable(quarkTile.tableName) .unwrap(CalciteSchema.class); dsBuilder.addAll(getDrivers(tileSchema)); }