当前位置: 首页>>代码示例>>Java>>正文


Java Table.getRowType方法代码示例

本文整理汇总了Java中org.apache.calcite.schema.Table.getRowType方法的典型用法代码示例。如果您正苦于以下问题:Java Table.getRowType方法的具体用法?Java Table.getRowType怎么用?Java Table.getRowType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.calcite.schema.Table的用法示例。


在下文中一共展示了Table.getRowType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createModify

import org.apache.calcite.schema.Table; //导入方法依赖的package包/类
/** Creates a relational expression to modify a table or modifiable view. */
private RelNode createModify(RelOptTable targetTable, RelNode source) {
	final ModifiableTable modifiableTable =
		targetTable.unwrap(ModifiableTable.class);
	if (modifiableTable != null) {
		return modifiableTable.toModificationRel(cluster, targetTable,
			catalogReader, source, LogicalTableModify.Operation.INSERT, null,
			null, false);
	}
	final ModifiableView modifiableView =
		targetTable.unwrap(ModifiableView.class);
	if (modifiableView != null) {
		final Table delegateTable = modifiableView.getTable();
		final RelDataType delegateRowType = delegateTable.getRowType(typeFactory);
		final RelOptTable delegateRelOptTable =
			RelOptTableImpl.create(null, delegateRowType, delegateTable,
				modifiableView.getTablePath());
		final RelNode newSource =
			createSource(targetTable, source, modifiableView, delegateRowType);
		return createModify(delegateRelOptTable, newSource);
	}
	return LogicalTableModify.create(targetTable, catalogReader, source,
		LogicalTableModify.Operation.INSERT, null, null, false);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:25,代码来源:SqlToRelConverter.java

示例2: visitTables

import org.apache.calcite.schema.Table; //导入方法依赖的package包/类
/**
 * 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());
      for (RelDataTypeField field: tableRow.getFieldList()) {
        if (shouldVisitColumn(schemaPath, tableName, field.getName())) {
          visitField(schemaPath, tableName, field);
        }
      }
    }
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:25,代码来源:InfoSchemaRecordGenerator.java

示例3: createModify

import org.apache.calcite.schema.Table; //导入方法依赖的package包/类
/** Creates a relational expression to modify a table or modifiable view. */
private RelNode createModify(RelOptTable targetTable, RelNode source) {
  final ModifiableTable modifiableTable =
      targetTable.unwrap(ModifiableTable.class);
  if (modifiableTable != null) {
    return modifiableTable.toModificationRel(cluster, targetTable,
        catalogReader, source, LogicalTableModify.Operation.INSERT, null,
        null, false);
  }
  final ModifiableView modifiableView =
      targetTable.unwrap(ModifiableView.class);
  if (modifiableView != null) {
    final Table delegateTable = modifiableView.getTable();
    final RelDataType delegateRowType = delegateTable.getRowType(typeFactory);
    final RelOptTable delegateRelOptTable =
        RelOptTableImpl.create(null, delegateRowType, delegateTable,
            modifiableView.getTablePath());
    final RelNode newSource =
        createSource(targetTable, source, modifiableView, delegateRowType);
    return createModify(delegateRelOptTable, newSource);
  }
  return LogicalTableModify.create(targetTable, catalogReader, source,
      LogicalTableModify.Operation.INSERT, null, null, false);
}
 
开发者ID:apache,项目名称:kylin,代码行数:25,代码来源:SqlToRelConverter.java

示例4: createModify

import org.apache.calcite.schema.Table; //导入方法依赖的package包/类
/** Creates a relational expression to modify a table or modifiable view. */
private RelNode createModify(RelOptTable targetTable, RelNode source) {
  final ModifiableTable modifiableTable =
      targetTable.unwrap(ModifiableTable.class);
  if (modifiableTable != null
      && modifiableTable == targetTable.unwrap(Table.class)) {
    return modifiableTable.toModificationRel(cluster, targetTable,
        catalogReader, source, LogicalTableModify.Operation.INSERT, null,
        null, false);
  }
  final ModifiableView modifiableView =
      targetTable.unwrap(ModifiableView.class);
  if (modifiableView != null) {
    final Table delegateTable = modifiableView.getTable();
    final RelDataType delegateRowType = delegateTable.getRowType(typeFactory);
    final RelOptTable delegateRelOptTable =
        RelOptTableImpl.create(null, delegateRowType, delegateTable,
            modifiableView.getTablePath());
    final RelNode newSource =
        createSource(targetTable, source, modifiableView, delegateRowType);
    return createModify(delegateRelOptTable, newSource);
  }
  return LogicalTableModify.create(targetTable, catalogReader, source,
      LogicalTableModify.Operation.INSERT, null, null, false);
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:SqlToRelConverter.java

示例5: scanSchema

import org.apache.calcite.schema.Table; //导入方法依赖的package包/类
/**
 * Recursively scans the given schema, invoking the visitor as appropriate.
 * @param  schemaPath  the path to the given schema, so far
 * @param  schema  the given schema
 */
private void scanSchema(String schemaPath, SchemaPlus schema) {

  // Recursively scan any subschema.
  for (String name: schema.getSubSchemaNames()) {
    scanSchema(schemaPath +
        (schemaPath == "" ? "" : ".") + // If we have an empty schema path, then don't insert a leading dot.
        name, schema.getSubSchema(name));
  }

  // Visit this schema and if requested ...
  if (shouldVisitSchema(schemaPath, schema) && visitSchema(schemaPath, schema)) {
    // ... do for each of the schema's tables.
    for (String tableName: schema.getTableNames()) {
      Table table = schema.getTable(tableName);

      if (table == null) {
        // Schema may return NULL for table if the query user doesn't have permissions to load the table. Ignore such
        // tables as INFO SCHEMA is about showing tables which the use has access to query.
        continue;
      }

      // Visit the table, and if requested ...
      if (shouldVisitTable(schemaPath, tableName) && visitTable(schemaPath,  tableName, table)) {
        // ... do for each of the table's fields.
        RelDataType tableRow = table.getRowType(new JavaTypeFactoryImpl());
        for (RelDataTypeField field: tableRow.getFieldList()) {
          visitField(schemaPath,  tableName, field);
        }
      }
    }
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:38,代码来源:RecordGenerator.java

示例6: checkConstraint

import org.apache.calcite.schema.Table; //导入方法依赖的package包/类
/**
 * Validates updates against the constraint of a modifiable view.
 *
 * @param validatorTable A {@link SqlValidatorTable} that may wrap a
 *                       ModifiableViewTable
 * @param update         The UPDATE parse tree node
 * @param targetRowType  The target type
 */
private void checkConstraint(
    SqlValidatorTable validatorTable,
    SqlUpdate update,
    RelDataType targetRowType) {
  final ModifiableViewTable modifiableViewTable =
      validatorTable.unwrap(ModifiableViewTable.class);
  if (modifiableViewTable != null) {
    final Table table = modifiableViewTable.unwrap(Table.class);
    final RelDataType tableRowType = table.getRowType(typeFactory);

    final Map<Integer, RexNode> projectMap =
        RelOptUtil.getColumnConstraints(modifiableViewTable, targetRowType,
            typeFactory);
    final Map<String, Integer> nameToIndex =
        SqlValidatorUtil.mapNameToIndex(tableRowType.getFieldList());

    // Validate update values against the view constraint.
    final List<SqlNode> targets = update.getTargetColumnList().getList();
    final List<SqlNode> sources = update.getSourceExpressionList().getList();
    for (final Pair<SqlNode, SqlNode> column : Pair.zip(targets, sources)) {
      final String columnName = ((SqlIdentifier) column.left).getSimple();
      final Integer columnIndex = nameToIndex.get(columnName);
      if (projectMap.containsKey(columnIndex)) {
        final RexNode columnConstraint = projectMap.get(columnIndex);
        final ValidationError validationError =
            new ValidationError(column.right,
                RESOURCE.viewConstraintNotSatisfied(columnName,
                    Util.last(validatorTable.getQualifiedName())));
        RelOptUtil.validateValueAgainstConstraint(column.right,
            columnConstraint, validationError);
      }
    }
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:43,代码来源:SqlValidatorImpl.java

示例7: getRowType

import org.apache.calcite.schema.Table; //导入方法依赖的package包/类
public RelDataType getRowType(RelDataTypeFactory typeFactory) {
  final List<RelDataType> typeList = new ArrayList<RelDataType>();
  final List<Integer> fieldCounts = new ArrayList<Integer>();
  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);
}
 
开发者ID:apache,项目名称:calcite,代码行数:16,代码来源:StarTable.java

示例8: extend

import org.apache.calcite.schema.Table; //导入方法依赖的package包/类
@Override protected RelOptTable extend(final Table extendedTable) {
  return new MockTable(catalogReader, names, stream, rowCount, resolver, initializerFactory) {
    @Override public RelDataType getRowType() {
      return extendedTable.getRowType(catalogReader.typeFactory);
    }
  };
}
 
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:MockCatalogReader.java

示例9: scanSchema

import org.apache.calcite.schema.Table; //导入方法依赖的package包/类
/**
 * Scan the schame tree, invoking the visitor as appropriate.
 * @param  rootSchema  the given schema
 */
public void scanSchema(SchemaPlus rootSchema) {
  if (!shouldVisitCatalog() || !visitCatalog()) {
    return;
  }

  // Visit this schema and if requested ...
  for (String subSchemaName: rootSchema.getSubSchemaNames()) {
    final SchemaPlus firstLevelSchema = rootSchema.getSubSchema(subSchemaName);

    if (shouldVisitSchema(subSchemaName, firstLevelSchema) && visitSchema(subSchemaName, firstLevelSchema)) {

      final AbstractSchema schemaInstance;
      try{
        schemaInstance = (AbstractSchema) firstLevelSchema.unwrap(AbstractSchema.class).getDefaultSchema();
      }catch(Exception ex){
        logger.warn("Failure reading schema {}. Skipping inclusion in INFORMATION_SCHEMA.", subSchemaName, ex);
        continue;
      }

      // ... do for each of the schema's tables.
      for (String tableName : firstLevelSchema.getTableNames()) {
        try {
          final TableInfo tableInfo = schemaInstance.getTableInfo(tableName);

          if (tableInfo == null) {
            // Schema may return NULL for table if the query user doesn't have permissions to load the table. Ignore such
            // tables as INFO SCHEMA is about showing tables which the user has access to query.
            continue;
          }
          final Table table;
          if (tableInfo.getTable() == null) {
            table = schemaInstance.getTable(tableName);
          } else {
            table = tableInfo.getTable();
          }
          final TableType tableType = table.getJdbcTableType();
          // Visit the table, and if requested ...
          if (shouldVisitTable(subSchemaName, tableName, tableType) && visitTable(subSchemaName, tableName, tableInfo)) {
            // ... do for each of the table's fields.
            RelDataType tableRow = table.getRowType(new JavaTypeFactoryImpl());
            for (RelDataTypeField field : tableRow.getFieldList()) {
              if (shouldVisitColumn(subSchemaName, tableName, field.getName())) {
                visitField(subSchemaName, tableName, field);
              }
            }
          }
        } catch (Exception e) {
          Joiner joiner = Joiner.on('.');
          String path = joiner.join(joiner.join(firstLevelSchema.getTableNames()), tableName);
          logger.warn("Failure while trying to read schema for table {}. Skipping inclusion in INFORMATION_SCHEMA.", path, e);;
          continue;
        }

      }
    }
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:62,代码来源:InfoSchemaRecordGenerator.java

示例10: defineMaterialization

import org.apache.calcite.schema.Table; //导入方法依赖的package包/类
/** Defines a new materialization. Returns its key. */
public MaterializationKey defineMaterialization(final CalciteSchema schema,
    TileKey tileKey, String viewSql, List<String> viewSchemaPath,
    String suggestedTableName, TableFactory tableFactory, boolean create,
    boolean existing) {
  final MaterializationActor.QueryKey queryKey =
      new MaterializationActor.QueryKey(viewSql, schema, viewSchemaPath);
  final MaterializationKey existingKey = actor.keyBySql.get(queryKey);
  if (existingKey != null) {
    return existingKey;
  }
  if (!create) {
    return null;
  }

  final CalciteConnection connection =
      CalciteMetaImpl.connect(schema.root(), null);
  CalciteSchema.TableEntry tableEntry;
  // If the user says the materialization exists, first try to find a table
  // with the name and if none can be found, lookup a view in the schema
  if (existing) {
    tableEntry = schema.getTable(suggestedTableName, true);
    if (tableEntry == null) {
      tableEntry = schema.getTableBasedOnNullaryFunction(suggestedTableName, true);
    }
  } else {
    tableEntry = null;
  }
  if (tableEntry == null) {
    tableEntry = schema.getTableBySql(viewSql);
  }

  RelDataType rowType = null;
  if (tableEntry == null) {
    Table table = tableFactory.createTable(schema, viewSql, viewSchemaPath);
    final String tableName = Schemas.uniqueTableName(schema,
        Util.first(suggestedTableName, "m"));
    tableEntry = schema.add(tableName, table, ImmutableList.of(viewSql));
    Hook.CREATE_MATERIALIZATION.run(tableName);
    rowType = table.getRowType(connection.getTypeFactory());
  }

  if (rowType == null) {
    // If we didn't validate the SQL by populating a table, validate it now.
    final CalcitePrepare.ParseResult parse =
        Schemas.parse(connection, schema, viewSchemaPath, viewSql);
    rowType = parse.rowType;
  }
  final MaterializationKey key = new MaterializationKey();
  final MaterializationActor.Materialization materialization =
      new MaterializationActor.Materialization(key, schema.root(),
          tableEntry, viewSql, rowType, viewSchemaPath);
  actor.keyMap.put(materialization.key, materialization);
  actor.keyBySql.put(queryKey, materialization.key);
  if (tileKey != null) {
    actor.keyByTile.put(tileKey, materialization.key);
  }
  return key;
}
 
开发者ID:apache,项目名称:calcite,代码行数:60,代码来源:MaterializationService.java

示例11: extend

import org.apache.calcite.schema.Table; //导入方法依赖的package包/类
@Override protected RelOptTable extend(Table extendedTable) {
  final RelDataType extendedRowType =
      extendedTable.getRowType(getRelOptSchema().getTypeFactory());
  return new RelOptTableImpl(getRelOptSchema(), extendedRowType, getQualifiedName(),
      extendedTable, expressionFunction, getRowCount());
}
 
开发者ID:apache,项目名称:calcite,代码行数:7,代码来源:RelOptTableImpl.java

示例12: resolve_

import org.apache.calcite.schema.Table; //导入方法依赖的package包/类
private void resolve_(final CalciteSchema rootSchema, List<String> names,
    List<String> schemaNames, SqlNameMatcher nameMatcher, Path path,
    Resolved resolved) {
  final List<String> concat = ImmutableList.<String>builder()
      .addAll(schemaNames).addAll(names).build();
  CalciteSchema schema = rootSchema;
  SqlValidatorNamespace namespace = null;
  List<String> remainingNames = concat;
  for (String schemaName : concat) {
    if (schema == rootSchema
        && nameMatcher.matches(schemaName, schema.name)) {
      remainingNames = Util.skip(remainingNames);
      continue;
    }
    final CalciteSchema subSchema =
        schema.getSubSchema(schemaName, nameMatcher.isCaseSensitive());
    if (subSchema != null) {
      path = path.plus(null, -1, subSchema.name, StructKind.NONE);
      remainingNames = Util.skip(remainingNames);
      schema = subSchema;
      namespace = new SchemaNamespace(validator,
          ImmutableList.copyOf(path.stepNames()));
      continue;
    }
    CalciteSchema.TableEntry entry =
        schema.getTable(schemaName, nameMatcher.isCaseSensitive());
    if (entry == null) {
      entry = schema.getTableBasedOnNullaryFunction(schemaName,
          nameMatcher.isCaseSensitive());
    }
    if (entry != null) {
      path = path.plus(null, -1, entry.name, StructKind.NONE);
      remainingNames = Util.skip(remainingNames);
      final Table table = entry.getTable();
      SqlValidatorTable table2 = null;
      if (table instanceof Wrapper) {
        table2 = ((Wrapper) table).unwrap(Prepare.PreparingTable.class);
      }
      if (table2 == null) {
        final RelOptSchema relOptSchema =
            validator.catalogReader.unwrap(RelOptSchema.class);
        final RelDataType rowType = table.getRowType(validator.typeFactory);
        table2 = RelOptTableImpl.create(relOptSchema, rowType, entry, null);
      }
      namespace = new TableNamespace(validator, table2);
      resolved.found(namespace, false, this, path, remainingNames);
      return;
    }
    // neither sub-schema nor table
    if (namespace != null
        && !remainingNames.equals(names)) {
      resolved.found(namespace, false, this, path, remainingNames);
    }
    return;
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:57,代码来源:EmptyScope.java


注:本文中的org.apache.calcite.schema.Table.getRowType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。