@Override public RelDataType getRowType(RelDataTypeFactory relDataTypeFactory) { return tbl.getRowType(relDataTypeFactory); }
.from(table.getRowType(typeFactory).getFieldList()) .transform( new Function<RelDataTypeField, Object[]>()
if (modifiableViewTable != null && source instanceof SqlCall) { final Table table = modifiableViewTable.unwrap(Table.class); final RelDataType tableRowType = table.getRowType(typeFactory); final List<RelDataTypeField> tableFields = tableRowType.getFieldList();
if (modifiableViewTable != null) { final Table table = modifiableViewTable.unwrap(Table.class); final RelDataType tableRowType = table.getRowType(typeFactory);
@Override public RelDataType getRowType(RelDataTypeFactory relDataTypeFactory) { return tbl.getRowType(relDataTypeFactory); }
@Override public RelDataType getRowType() { return extendedTable.getRowType(catalogReader.typeFactory); } };
@Override public RelDataType getRowType() { return extendedTable.getRowType(catalogReader.typeFactory); } };
public RelDataType getRowType(RelDataTypeFactory typeFactory, List<Object> arguments) { return apply(arguments).getRowType(typeFactory); }
/** * Gets the data-type of all columns in a table (for a view table: including * columns of the underlying table) */ private RelDataType getBaseRowType() { final Table schemaTable = table.unwrap(Table.class); if (schemaTable instanceof ModifiableViewTable) { final Table underlying = ((ModifiableViewTable) schemaTable).unwrap(Table.class); assert underlying != null; return underlying.getRowType(validator.typeFactory); } return schemaTable.getRowType(validator.typeFactory); }
public RelDataType getRowType(RelDataTypeFactory typeFactory, List<Object> arguments) { return apply(arguments).getRowType(typeFactory); }
/** * Gets the data-type of all columns in a table (for a view table: including * columns of the underlying table) */ private RelDataType getBaseRowType() { final Table schemaTable = table.unwrap(Table.class); if (schemaTable instanceof ModifiableViewTable) { final Table underlying = ((ModifiableViewTable) schemaTable).unwrap(Table.class); assert underlying != null; return underlying.getRowType(validator.typeFactory); } return schemaTable.getRowType(validator.typeFactory); }
public RelDataType getRowType(RelDataTypeFactory typeFactory) { final List<RelDataType> typeList = new ArrayList<>(); final List<Integer> fieldCounts = new ArrayList<>(); for (Table table : tables) { final RelDataType rowType = table.getRowType(typeFactory); typeList.addAll(RelOptUtil.getFieldTypeList(rowType)); fieldCounts.add(rowType.getFieldCount()); } // Compute fieldCounts the first time this method is called. Safe to assume // that the field counts will be the same whichever type factory is used. if (this.fieldCounts == null) { this.fieldCounts = ImmutableIntList.copyOf(fieldCounts); } return typeFactory.createStructType(typeList, lattice.uniqueColumnNames); }
public RelDataType getRowType(RelDataTypeFactory typeFactory) { final List<RelDataType> typeList = new ArrayList<>(); final List<Integer> fieldCounts = new ArrayList<>(); for (Table table : tables) { final RelDataType rowType = table.getRowType(typeFactory); typeList.addAll(RelOptUtil.getFieldTypeList(rowType)); fieldCounts.add(rowType.getFieldCount()); } // Compute fieldCounts the first time this method is called. Safe to assume // that the field counts will be the same whichever type factory is used. if (this.fieldCounts == null) { this.fieldCounts = ImmutableIntList.copyOf(fieldCounts); } return typeFactory.createStructType(typeList, lattice.uniqueColumnNames()); }
public Prepare.PreparingTable getTable(final List<String> names) { // First look in the default schema, if any. // If not found, look in the root schema. CalciteSchema.TableEntry entry = SqlValidatorUtil.getTableEntry(this, names); if (entry != null) { final Table table = entry.getTable(); if (table instanceof Wrapper) { final Prepare.PreparingTable relOptTable = ((Wrapper) table).unwrap(Prepare.PreparingTable.class); if (relOptTable != null) { return relOptTable; } } return RelOptTableImpl.create(this, table.getRowType(typeFactory), entry, null); } return null; }
public Prepare.PreparingTable getTable(final List<String> names) { // First look in the default schema, if any. // If not found, look in the root schema. CalciteSchema.TableEntry entry = SqlValidatorUtil.getTableEntry(this, names); if (entry != null) { final Table table = entry.getTable(); if (table instanceof Wrapper) { final Prepare.PreparingTable relOptTable = ((Wrapper) table).unwrap(Prepare.PreparingTable.class); if (relOptTable != null) { return relOptTable; } } return RelOptTableImpl.create(this, table.getRowType(typeFactory), entry, null); } return null; }
@Override protected RelOptTable extend(Table extendedTable) { final RelDataType extendedRowType = extendedTable.getRowType(getRelOptSchema().getTypeFactory()); return new RelOptTableImpl(getRelOptSchema(), extendedRowType, getQualifiedName(), extendedTable, expressionFunction, getRowCount()); }
@Override protected RelOptTable extend(Table extendedTable) { final RelDataType extendedRowType = extendedTable.getRowType(getRelOptSchema().getTypeFactory()); return new RelOptTableImpl(getRelOptSchema(), extendedRowType, getQualifiedName(), extendedTable, expressionFunction, getRowCount()); }
/** * Visit the tables in the given schema. The * @param schemaPath the path to the given schema * @param schema the given schema */ public void visitTables(String schemaPath, SchemaPlus schema) { final AbstractSchema drillSchema = schema.unwrap(AbstractSchema.class); final List<String> tableNames = Lists.newArrayList(schema.getTableNames()); for(Pair<String, ? extends Table> tableNameToTable : drillSchema.getTablesByNames(tableNames)) { final String tableName = tableNameToTable.getKey(); final Table table = tableNameToTable.getValue(); final TableType tableType = table.getJdbcTableType(); // Visit the table, and if requested ... if(shouldVisitTable(schemaPath, tableName, tableType) && visitTable(schemaPath, tableName, table)) { // ... do for each of the table's fields. final RelDataType tableRow = table.getRowType(new JavaTypeFactoryImpl(DRILL_REL_DATATYPE_SYSTEM)); for (RelDataTypeField field: tableRow.getFieldList()) { if (shouldVisitColumn(schemaPath, tableName, field.getName())) { visitField(schemaPath, tableName, field); } } } } }
@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 void populateMaterializationsAndLattice( QuarkMaterializeCluster.RelOptPlannerHolder plannerHolder, CalciteSchema rootSchema) { if (materializations == null) { materializations = MaterializationService.instance().query(rootSchema); } Materializer materializer = new Materializer(materializations); materializer.populateMaterializations(context.getPrepareContext(), plannerHolder); List<CalciteSchema.LatticeEntry> lattices = Schemas.getLatticeEntries(rootSchema); for (CalciteSchema.LatticeEntry lattice : lattices) { final CalciteSchema.TableEntry starTable = lattice.getStarTable(); final JavaTypeFactory typeFactory = context.getTypeFactory(); final RelOptTableImpl starRelOptTable = RelOptTableImpl.create(catalogReader, starTable.getTable().getRowType(typeFactory), starTable, null); plannerHolder.getPlanner().addLattice( new RelOptLattice(lattice.getLattice(), starRelOptTable)); } } }