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


Java Table类代码示例

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


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

示例1: insertCopying

import org.apache.calcite.schema.Table; //导入依赖的package包/类
public JdbcRelBuilder insertCopying(
		LogicalTableModify original,
		Table table
) {
	List<String> name = JdbcTableUtils.getQualifiedName(original.getTable(), table);

	push(new LogicalTableModify(
			cluster,
			original.getTraitSet(),
			relOptSchema.getTableForMember(name),
			original.getCatalogReader(),
			peek(),
			TableModify.Operation.INSERT,
			null,
			null,
			original.isFlattened()
	));
	return this;
}
 
开发者ID:tzolov,项目名称:calcite-sql-rewriter,代码行数:20,代码来源:JdbcRelBuilder.java

示例2: apply

import org.apache.calcite.schema.Table; //导入依赖的package包/类
@Override
public RelNode apply(RelNode originalRel, JdbcRelBuilderFactory relBuilderFactory) {

	if (!(originalRel instanceof LogicalTableModify)) {
		return null;
	}

	LogicalTableModify tableModify = (LogicalTableModify) originalRel;

	if (tableModify.getOperation() != operation) {
		return null;
	}

	Table baseTable = JdbcTableUtils.getJdbcTable(tableModify);
	if (!(baseTable instanceof JournalledJdbcTable)) {
		// Not a journal table; nothing to do
		return null;
	}
	JournalledJdbcTable journalTable = (JournalledJdbcTable) baseTable;

	return doApply(tableModify, journalTable, relBuilderFactory);
}
 
开发者ID:tzolov,项目名称:calcite-sql-rewriter,代码行数:23,代码来源:AbstractForcedRule.java

示例3: getPlan

import org.apache.calcite.schema.Table; //导入依赖的package包/类
@Override
public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException, ForemanSetupException {
  SqlDropView dropView = unwrap(sqlNode, SqlDropView.class);
  final String viewToDrop = dropView.getName();
  final AbstractSchema drillSchema =
      SchemaUtilites.resolveToMutableDrillSchema(context.getNewDefaultSchema(), dropView.getSchemaPath());

  final String schemaPath = drillSchema.getFullSchemaName();

  final Table existingTable = SqlHandlerUtil.getTableFromSchema(drillSchema, viewToDrop);
  if (existingTable != null && existingTable.getJdbcTableType() != Schema.TableType.VIEW) {
    throw UserException.validationError()
        .message("[%s] is not a VIEW in schema [%s]", viewToDrop, schemaPath)
        .build(logger);
  } else if (existingTable == null) {
    throw UserException.validationError()
        .message("Unknown view [%s] in schema [%s].", viewToDrop, schemaPath)
        .build(logger);
  }

  drillSchema.dropView(viewToDrop);

  return DirectPlan.createDirectPlan(context, true,
      String.format("View [%s] deleted successfully from schema [%s].", viewToDrop, schemaPath));
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:26,代码来源:ViewHandler.java

示例4: getTable

import org.apache.calcite.schema.Table; //导入依赖的package包/类
public Table getTable(SchemaPlus rootSchema){
  List<FolderName> components = this.getFolderPath();
  SchemaPlus schema = rootSchema.getSubSchema(this.getRoot().getName());
  if(schema == null){
    throw new IllegalStateException(String.format("Failure finding schema path %s in position 0 of path %s", getRoot().getName(), toPathString()));
  }

  int i = 1;
  for(FolderName folder : components){
    schema = schema.getSubSchema(folder.getName());
    if(schema == null){
      throw new IllegalStateException(String.format("Failure finding schema path %s in position %d of path %s", folder.getName(), i, toPathString()));
    }
    i++;
  }
  Table table = schema.getTable(getLeaf().getName());
  if(table == null){
    throw new IllegalStateException(String.format("Failure finding table in path %s. The schema exists but no table in that schema matches %s", toPathString(), getLeaf().getName()));
  }

  return table;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:DatasetPath.java

示例5: getColumnList

import org.apache.calcite.schema.Table; //导入依赖的package包/类
public List<String> getColumnList(final String username, DatasetPath path) {
  final SchemaConfig schemaConfig = SchemaConfig.newBuilder(username)
      .setProvider(new SchemaInfoProvider() {
        private final ViewExpansionContext viewExpansionContext = new ViewExpansionContext(this, schemaProvider, username);

        @Override
        public ViewExpansionContext getViewExpansionContext() {
          return viewExpansionContext;
        }

        @Override
        public OptionValue getOption(String optionKey) {
          throw new UnsupportedOperationException();
        }
      })
      .build();
  final SchemaPlus schema = schemaProvider.getRootSchema(schemaConfig);
  final Table table = path.getTable(schema);
  return table.getRowType(new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT)).getFieldNames();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:21,代码来源:QueryExecutor.java

示例6: 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

示例7: create

import org.apache.calcite.schema.Table; //导入依赖的package包/类
/** Creates an DirPrunedEnumerableTableScan. */
public static EnumerableTableScan create(RelOptCluster cluster,
    RelOptTable relOptTable, String digestFromSelection) {
  final Table table = relOptTable.unwrap(Table.class);
  Class elementType = EnumerableTableScan.deduceElementType(table);
  final RelTraitSet traitSet =
      cluster.traitSetOf(EnumerableConvention.INSTANCE)
          .replaceIfs(RelCollationTraitDef.INSTANCE,
              new Supplier<List<RelCollation>>() {
                public List<RelCollation> get() {
                  if (table != null) {
                    return table.getStatistic().getCollations();
                  }
                  return ImmutableList.of();
                }
              });
  return new DirPrunedEnumerableTableScan(cluster, traitSet, relOptTable, elementType, digestFromSelection);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:19,代码来源:DirPrunedEnumerableTableScan.java

示例8: getDirectTable

import org.apache.calcite.schema.Table; //导入依赖的package包/类
private Table getDirectTable(String name) {
  Pattern p = Pattern.compile("(\\w+)_(\\d+)(k|m)?", Pattern.CASE_INSENSITIVE);
  Matcher m = p.matcher(name);
  if (! m.matches()) {
    return null;
  }
  @SuppressWarnings("unused")
  String baseName = m.group(1);
  int n = Integer.parseInt(m.group(2));
  String unit = m.group(3);
  if (unit == null) { }
  else if (unit.equalsIgnoreCase("K")) { n *= 1000; }
  else if (unit.equalsIgnoreCase("M")) { n *= 1_000_000; }
  MockTableDef.MockScanEntry entry = new MockTableDef.MockScanEntry(n, true, 0, 1, null);
  List<MockTableDef.MockScanEntry> list = new ArrayList<>();
  list.add(entry);
  return new DynamicDrillTable(engine, this.name, list);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:19,代码来源:MockStorageEngine.java

示例9: 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

示例10: getTable

import org.apache.calcite.schema.Table; //导入依赖的package包/类
@Override
public Table getTable(String name) {
  Schema schema = getDefaultSchema();

  if (schema != null) {
    try {
      Table t = schema.getTable(name);
      if (t != null) {
        return t;
      }
      return schema.getTable(name.toUpperCase());
    } catch (RuntimeException e) {
      logger.warn("Failure while attempting to read table '{}' from JDBC source.", name, e);

    }
  }

  // no table was found.
  return null;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:21,代码来源:JdbcStoragePlugin.java

示例11: getTablesByNamesByBulkLoad

import org.apache.calcite.schema.Table; //导入依赖的package包/类
@Override
public List<Pair<String, ? extends Table>> getTablesByNamesByBulkLoad(final List<String> tableNames,
    final int bulkSize) {
  final String schemaName = getName();
  final List<org.apache.hadoop.hive.metastore.api.Table> tables = DrillHiveMetaStoreClient
      .getTablesByNamesByBulkLoadHelper(mClient, tableNames, schemaName, bulkSize);

  final List<Pair<String, ? extends Table>> tableNameToTable = Lists.newArrayList();
  for (final org.apache.hadoop.hive.metastore.api.Table table : tables) {
    if (table == null) {
      continue;
    }

    final String tableName = table.getTableName();
    final TableType tableType;
    if (table.getTableType().equals(org.apache.hadoop.hive.metastore.TableType.VIRTUAL_VIEW.toString())) {
      tableType = TableType.VIEW;
    } else {
      tableType = TableType.TABLE;
    }
    tableNameToTable.add(Pair.of(tableName, new HiveTableWithoutStatisticAndRowType(tableType)));
  }
  return tableNameToTable;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:25,代码来源:HiveDatabaseSchema.java

示例12: addImplicitTablesBasedOnNullaryFunctionsToBuilder

import org.apache.calcite.schema.Table; //导入依赖的package包/类
protected void addImplicitTablesBasedOnNullaryFunctionsToBuilder(
        ImmutableSortedMap.Builder<String, Table> builder) {
    ImmutableSortedMap<String, Table> explicitTables = builder.build();

    for (String s : implicitFunctionCache.get(System.currentTimeMillis())) {
        // explicit table wins.
        if (explicitTables.containsKey(s)) {
            continue;
        }
        for (Function function : getSchema().getFunctions(s)) {
            if (function instanceof TableMacro
                    && function.getParameters().isEmpty()) {
                final Table table = ((TableMacro) function).apply(ImmutableList.of());
                builder.put(s, table);
            }
        }
    }
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:19,代码来源:CachingCalciteSchema.java

示例13: getImplicitTableBasedOnNullaryFunction

import org.apache.calcite.schema.Table; //导入依赖的package包/类
protected TableEntry getImplicitTableBasedOnNullaryFunction(String tableName,
                                                            boolean caseSensitive) {
    final NavigableSet<String> set =
            implicitFunctionCache.get(System.currentTimeMillis());
    for (String s : find(set, tableName)) {
        for (Function function : getSchema().getFunctions(s)) {
            if (function instanceof TableMacro
                    && function.getParameters().isEmpty()) {
                final Table table =
                        ((TableMacro) function).apply(ImmutableList.of());
                return tableEntry(tableName, table);
            }
        }
    }
    return null;
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:17,代码来源:CachingCalciteSchema.java

示例14: addImplicitTablesBasedOnNullaryFunctionsToBuilder

import org.apache.calcite.schema.Table; //导入依赖的package包/类
protected void addImplicitTablesBasedOnNullaryFunctionsToBuilder(
        ImmutableSortedMap.Builder<String, Table> builder) {
    ImmutableSortedMap<String, Table> explicitTables = builder.build();

    for (String s : getSchema().getFunctionNames()) {
        // explicit table wins.
        if (explicitTables.containsKey(s)) {
            continue;
        }
        for (Function function : getSchema().getFunctions(s)) {
            if (function instanceof TableMacro
                    && function.getParameters().isEmpty()) {
                final Table table = ((TableMacro) function).apply(ImmutableList.of());
                builder.put(s, table);
            }
        }
    }
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:19,代码来源:SimpleCalciteSchema.java

示例15: getTablesBasedOnNullaryFunctions

import org.apache.calcite.schema.Table; //导入依赖的package包/类
/**
 * Returns tables derived from explicit and implicit functions
 * that take zero parameters.
 */
public final NavigableMap<String, Table> getTablesBasedOnNullaryFunctions() {
    ImmutableSortedMap.Builder<String, Table> builder =
            new ImmutableSortedMap.Builder<>(COMPARATOR);
    for (Map.Entry<String, FunctionEntry> s : nullaryFunctionMap.entrySet()) {
        final Function function = s.getValue().getFunction();
        if (function instanceof TableMacro) {
            assert function.getParameters().isEmpty();
            final Table table = ((TableMacro) function).apply(ImmutableList.of());
            builder.put(s.getKey(), table);
        }
    }
    // add tables derived from implicit functions
    addImplicitTablesBasedOnNullaryFunctionsToBuilder(builder);
    return Compatible.INSTANCE.navigableMap(builder.build());
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:20,代码来源:CalciteSchema.java


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