• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CalciteSchema类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: schemas

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
Enumerable<MetaSchema> schemas(String catalog) {
    return Linq4j.asEnumerable(
            getConnection().getCalciteRootSchema().getSubSchemaMap().values())
            .select(
                    new Function1<CalciteSchema, MetaSchema>() {
                        public MetaSchema apply(CalciteSchema calciteSchema) {
                            return new CalciteMetaSchema(
                                    calciteSchema,
                                    connection.getCatalog(),
                                    calciteSchema.getName());
                        }
                    })
            .orderBy(
                    new Function1<MetaSchema, Comparable>() {
                        public Comparable apply(MetaSchema metaSchema) {
                            return (Comparable) FlatLists.of(
                                    Util.first(metaSchema.tableCatalog, ""),
                                    metaSchema.tableSchem);
                        }
                    });
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:22,代码来源:CalciteMetaImpl.java


示例2: connect

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
/**
 * Creates an internal connection.
 */
CalciteConnection connect(CalciteSchema rootSchema,
                          JavaTypeFactory typeFactory) {
    /*
    return (CalciteConnection) ((CalciteFactory) factory)
            .newConnection(this, factory, CONNECT_STRING_PREFIX, new Properties(),
                    rootSchema, typeFactory);
                    */

    System.out.println("********************************************************************");
    System.out.println("********************************************************************");
    System.out.println("********************************************************************");
    System.out.println("********************************************************************");
    System.out.println("********************************************************************");
    return (CalciteConnection) ((CalciteFactory) factory)
            .newConnection(this, factory, CONNECT_STRING_PREFIX, new Properties(),
                    (CalciteSchema) SchemaManager.getSingletonInstance(null).getCurrentSchema(),
                    typeFactory);
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:22,代码来源:Driver.java


示例3: CalciteConnectionImpl

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
/**
 * Creates a CalciteConnectionImpl.
 * <p/>
 * <p>Not public; method is called only from the driver.</p>
 *
 * @param driver      Driver
 * @param factory     Factory for JDBC objects
 * @param url         Server URL
 * @param info        Other connection properties
 * @param rootSchema  Root schema, or null
 * @param typeFactory Type factory, or null
 */
protected CalciteConnectionImpl(Driver driver, AvaticaFactory factory,
                                String url, Properties info, CalciteSchema rootSchema,
                                JavaTypeFactory typeFactory) {
    super(driver, factory, url, info);
    CalciteConnectionConfig cfg = new CalciteConnectionConfigImpl(info);
    this.prepareFactory = driver.getPrepareFactory();
    if (typeFactory != null) {
        this.typeFactory = typeFactory;
    } else {
        final RelDataTypeSystem typeSystem =
                cfg.typeSystem(RelDataTypeSystem.class, RelDataTypeSystem.DEFAULT);
        this.typeFactory = new JavaTypeFactoryImpl(typeSystem);
    }
    this.rootSchema =
            Preconditions.checkNotNull(rootSchema != null
                    ? rootSchema
                    : CalciteSchema.createRootSchema(true));
    Preconditions.checkArgument(this.rootSchema.isRoot(), "must be root schema");
    this.properties.put(InternalProperty.CASE_SENSITIVE, cfg.caseSensitive());
    this.properties.put(InternalProperty.UNQUOTED_CASING, cfg.unquotedCasing());
    this.properties.put(InternalProperty.QUOTED_CASING, cfg.quotedCasing());
    this.properties.put(InternalProperty.QUOTING, cfg.quoting());
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:36,代码来源:CalciteConnectionImpl.java


示例4: populateMaterializationsAndLattice

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
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));
  }
}
 
开发者ID:qubole,项目名称:quark,代码行数:24,代码来源:SqlWorker.java


示例5: populateMaterializations

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
protected void populateMaterializations(Context context,
                                        RelOptPlanner planner, Prepare.Materialization materialization) {
  // REVIEW: initialize queryRel and tableRel inside MaterializationService,
  // not here?
  try {
    final CalciteSchema schema = materialization.materializedTable.schema;
    CalciteCatalogReader catalogReader =
        new CalciteCatalogReader(
            schema.root(),
            context.config().caseSensitive(),
            materialization.viewSchemaPath,
            context.getTypeFactory());
    final CalciteMaterializer materializer =
        new CalciteMaterializer(this, context, catalogReader, schema, planner,
            createConvertletTable());
    materializer.populate(materialization);
  } catch (Exception e) {
    throw new RuntimeException("While populating materialization "
        + materialization.materializedTable.path(), e);
  }
}
 
开发者ID:apache,项目名称:kylin,代码行数:22,代码来源:CalcitePrepareImpl.java


示例6: perform

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
/** Executes a prepare action. */
public <R> R perform(CalciteServerStatement statement,
    Frameworks.PrepareAction<R> action) {
  final CalcitePrepare.Context prepareContext =
      statement.createPrepareContext();
  final JavaTypeFactory typeFactory = prepareContext.getTypeFactory();
  final CalciteSchema schema =
      action.getConfig().getDefaultSchema() != null
          ? CalciteSchema.from(action.getConfig().getDefaultSchema())
          : prepareContext.getRootSchema();
  CalciteCatalogReader catalogReader =
      new CalciteCatalogReader(schema.root(),
          prepareContext.config().caseSensitive(),
          schema.path(null),
          typeFactory);
  final RexBuilder rexBuilder = new RexBuilder(typeFactory);
  final RelOptPlanner planner =
      createPlanner(prepareContext,
          action.getConfig().getContext(),
          action.getConfig().getCostFactory());
  final RelOptCluster cluster = createCluster(planner, rexBuilder);
  return action.apply(cluster, catalogReader,
      prepareContext.getRootSchema().plus(), statement);
}
 
开发者ID:apache,项目名称:kylin,代码行数:25,代码来源:CalcitePrepareImpl.java


示例7: CalcitePreparingStmt

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
public CalcitePreparingStmt(CalcitePrepareImpl prepare,
    Context context,
    CatalogReader catalogReader,
    RelDataTypeFactory typeFactory,
    CalciteSchema schema,
    EnumerableRel.Prefer prefer,
    RelOptPlanner planner,
    Convention resultConvention,
    SqlRexConvertletTable convertletTable) {
  super(context, catalogReader, resultConvention);
  this.prepare = prepare;
  this.schema = schema;
  this.prefer = prefer;
  this.planner = planner;
  this.typeFactory = typeFactory;
  this.convertletTable = convertletTable;
  this.rexBuilder = new RexBuilder(typeFactory);
}
 
开发者ID:apache,项目名称:kylin,代码行数:19,代码来源:CalcitePrepareImpl.java


示例8: execute

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
public void execute(CalcitePrepare.Context context) {
  final Pair<CalciteSchema, String> pair =
      SqlDdlNodes.schema(context, true, name);
  final SchemaPlus schemaPlus = pair.left.plus();
  for (Function function : schemaPlus.getFunctions(pair.right)) {
    if (function.getParameters().isEmpty()) {
      if (!getReplace()) {
        throw SqlUtil.newContextException(name.getParserPosition(),
            RESOURCE.viewExists(pair.right));
      }
      pair.left.removeFunction(pair.right);
    }
  }
  final SqlNode q = SqlDdlNodes.renameColumns(columnList, query);
  final String sql = q.toSqlString(CalciteSqlDialect.DEFAULT).getSql();
  final ViewTableMacro viewTableMacro =
      ViewTable.viewMacro(schemaPlus, sql, pair.left.path(null),
          context.getObjectPath(), false);
  final TranslatableTable x = viewTableMacro.apply(ImmutableList.of());
  Util.discard(x);
  schemaPlus.add(pair.right, viewTableMacro);
}
 
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:SqlCreateView.java


示例9: execute

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
@Override public void execute(CalcitePrepare.Context context) {
  final Pair<CalciteSchema, String> pair =
      SqlDdlNodes.schema(context, true, name);
  final Table table = pair.left.plus().getTable(pair.right);
  if (table != null) {
    // Materialized view exists.
    super.execute(context);
    if (table instanceof Wrapper) {
      final MaterializationKey materializationKey =
          ((Wrapper) table).unwrap(MaterializationKey.class);
      if (materializationKey != null) {
        MaterializationService.instance()
            .removeMaterialization(materializationKey);
      }
    }
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:SqlDropMaterializedView.java


示例10: visit

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
public void visit(JsonLattice jsonLattice) {
  try {
    checkRequiredAttributes(jsonLattice, "name", "sql");
    final SchemaPlus schema = currentSchema();
    if (!schema.isMutable()) {
      throw new RuntimeException("Cannot define lattice; parent schema '"
          + currentSchemaName()
          + "' is not a SemiMutableSchema");
    }
    CalciteSchema calciteSchema = CalciteSchema.from(schema);
    Lattice.Builder latticeBuilder =
        Lattice.builder(calciteSchema, jsonLattice.getSql())
            .auto(jsonLattice.auto)
            .algorithm(jsonLattice.algorithm);
    if (jsonLattice.rowCountEstimate != null) {
      latticeBuilder.rowCountEstimate(jsonLattice.rowCountEstimate);
    }
    if (jsonLattice.statisticProvider != null) {
      latticeBuilder.statisticProvider(jsonLattice.statisticProvider);
    }
    populateLattice(jsonLattice, latticeBuilder);
    schema.add(jsonLattice.name, latticeBuilder.build());
  } catch (Exception e) {
    throw new RuntimeException("Error instantiating " + jsonLattice, e);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:ModelHandler.java


示例11: useStar

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
/** Converts a relational expression to use a
 * {@link org.apache.calcite.schema.impl.StarTable} defined in {@code schema}.
 * Uses the first star table that fits. */
private Iterable<Callback> useStar(CalciteSchema schema, RelNode queryRel) {
  List<CalciteSchema.TableEntry> starTables =
      Schemas.getStarTables(schema.root());
  if (starTables.isEmpty()) {
    // Don't waste effort converting to leaf-join form.
    return ImmutableList.of();
  }
  final List<Callback> list = Lists.newArrayList();
  final RelNode rel2 =
      RelOptMaterialization.toLeafJoinForm(queryRel);
  for (CalciteSchema.TableEntry starTable : starTables) {
    final Table table = starTable.getTable();
    assert table instanceof StarTable;
    RelOptTableImpl starRelOptTable =
        RelOptTableImpl.create(catalogReader, table.getRowType(typeFactory),
            starTable, null);
    final RelNode rel3 =
        RelOptMaterialization.tryUseStar(rel2, starRelOptTable);
    if (rel3 != null) {
      list.add(new Callback(rel3, starTable, starRelOptTable));
    }
  }
  return list;
}
 
开发者ID:apache,项目名称:calcite,代码行数:28,代码来源:CalciteMaterializer.java


示例12: populateMaterializations

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
protected void populateMaterializations(Context context,
    RelOptPlanner planner, Prepare.Materialization materialization) {
  // REVIEW: initialize queryRel and tableRel inside MaterializationService,
  // not here?
  try {
    final CalciteSchema schema = materialization.materializedTable.schema;
    CalciteCatalogReader catalogReader =
        new CalciteCatalogReader(
            schema.root(),
            materialization.viewSchemaPath,
            context.getTypeFactory(),
            context.config());
    final CalciteMaterializer materializer =
        new CalciteMaterializer(this, context, catalogReader, schema, planner,
            createConvertletTable());
    materializer.populate(materialization);
  } catch (Exception e) {
    throw new RuntimeException("While populating materialization "
        + materialization.materializedTable.path(), e);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:CalcitePrepareImpl.java


示例13: perform

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
/** Executes a prepare action. */
public <R> R perform(CalciteServerStatement statement,
    Frameworks.PrepareAction<R> action) {
  final CalcitePrepare.Context prepareContext =
      statement.createPrepareContext();
  final JavaTypeFactory typeFactory = prepareContext.getTypeFactory();
  final CalciteSchema schema =
      action.getConfig().getDefaultSchema() != null
          ? CalciteSchema.from(action.getConfig().getDefaultSchema())
          : prepareContext.getRootSchema();
  CalciteCatalogReader catalogReader =
      new CalciteCatalogReader(schema.root(),
          schema.path(null),
          typeFactory,
          prepareContext.config());
  final RexBuilder rexBuilder = new RexBuilder(typeFactory);
  final RelOptPlanner planner =
      createPlanner(prepareContext,
          action.getConfig().getContext(),
          action.getConfig().getCostFactory());
  final RelOptCluster cluster = createCluster(planner, rexBuilder);
  return action.apply(cluster, catalogReader,
      prepareContext.getRootSchema().plus(), statement);
}
 
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:CalcitePrepareImpl.java


示例14: CalcitePreparingStmt

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
CalcitePreparingStmt(CalcitePrepareImpl prepare,
    Context context,
    CatalogReader catalogReader,
    RelDataTypeFactory typeFactory,
    CalciteSchema schema,
    EnumerableRel.Prefer prefer,
    RelOptPlanner planner,
    Convention resultConvention,
    SqlRexConvertletTable convertletTable) {
  super(context, catalogReader, resultConvention);
  this.prepare = prepare;
  this.schema = schema;
  this.prefer = prefer;
  this.planner = planner;
  this.typeFactory = typeFactory;
  this.convertletTable = convertletTable;
  this.rexBuilder = new RexBuilder(typeFactory);
}
 
开发者ID:apache,项目名称:calcite,代码行数:19,代码来源:CalcitePrepareImpl.java


示例15: toRel

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
RelNode toRel(Queryable<T> queryable) {
  if (queryable instanceof QueryableDefaults.Replayable) {
    //noinspection unchecked
    ((QueryableDefaults.Replayable) queryable).replay(this);
    return rel;
  }
  if (queryable instanceof AbstractTableQueryable) {
    final AbstractTableQueryable tableQueryable =
        (AbstractTableQueryable) queryable;
    final QueryableTable table = tableQueryable.table;
    final CalciteSchema.TableEntry tableEntry =
        CalciteSchema.from(tableQueryable.schema)
            .add(tableQueryable.tableName, tableQueryable.table);
    final RelOptTableImpl relOptTable =
        RelOptTableImpl.create(null, table.getRowType(translator.typeFactory),
            tableEntry, null);
    if (table instanceof TranslatableTable) {
      return ((TranslatableTable) table).toRel(translator, relOptTable);
    } else {
      return LogicalTableScan.create(translator.cluster, relOptTable);
    }
  }
  return translator.translate(queryable.getExpression());
}
 
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:QueryableRelBuilder.java


示例16: unwrap

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
public <T> T unwrap(Class<T> clazz) {
  if (clazz.isInstance(this)) {
    return clazz.cast(this);
  }
  if (clazz.isInstance(table)) {
    return clazz.cast(table);
  }
  if (table instanceof Wrapper) {
    final T t = ((Wrapper) table).unwrap(clazz);
    if (t != null) {
      return t;
    }
  }
  if (clazz == CalciteSchema.class) {
    return clazz.cast(
        Schemas.subSchema(((CalciteCatalogReader) schema).rootSchema,
            Util.skipLast(getQualifiedName())));
  }
  return null;
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:RelOptTableImpl.java


示例17: getTable

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:calcite,代码行数:19,代码来源:CalciteCatalogReader.java


示例18: operatorTable

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
/** Creates an operator table that contains functions in the given class.
 *
 * @see ModelHandler#addFunctions */
public static SqlOperatorTable operatorTable(String className) {
  // Dummy schema to collect the functions
  final CalciteSchema schema =
      CalciteSchema.createRootSchema(false, false);
  ModelHandler.addFunctions(schema.plus(), null, ImmutableList.<String>of(),
      className, "*", true);

  // The following is technical debt; see [CALCITE-2082] Remove
  // RelDataTypeFactory argument from SqlUserDefinedAggFunction constructor
  final SqlTypeFactoryImpl typeFactory =
      new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);

  final ListSqlOperatorTable table = new ListSqlOperatorTable();
  for (String name : schema.getFunctionNames()) {
    for (Function function : schema.getFunctions(name, true)) {
      final SqlIdentifier id = new SqlIdentifier(name, SqlParserPos.ZERO);
      table.add(
          toOp(typeFactory, id, function));
    }
  }
  return table;
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:CalciteCatalogReader.java


示例19: findTable

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
private Table findTable(CalciteSchema schema, String tableName, boolean caseSensitive) {
  CalciteSchema.TableEntry entry = schema.getTable(tableName, caseSensitive);
  if (entry != null) {
    return entry.getTable();
  }

  // Check sub schemas
  for (CalciteSchema subSchema : schema.getSubSchemaMap().values()) {
    Table table = findTable(subSchema, tableName, caseSensitive);
    if (table != null) {
      return table;
    }
  }

  return null;
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:SqlValidatorImpl.java


示例20: getTableEntry

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
/**
 * Finds a {@link org.apache.calcite.jdbc.CalciteSchema.TableEntry} in a
 * given catalog reader whose table has the given name, possibly qualified.
 *
 * <p>Uses the case-sensitivity policy of the specified catalog reader.
 *
 * <p>If not found, returns null.
 *
 * @param catalogReader accessor to the table metadata
 * @param names Name of table, may be qualified or fully-qualified
 *
 * @return TableEntry with a table with the given name, or null
 */
public static CalciteSchema.TableEntry getTableEntry(
    SqlValidatorCatalogReader catalogReader, List<String> names) {
  // First look in the default schema, if any.
  // If not found, look in the root schema.
  for (List<String> schemaPath : catalogReader.getSchemaPaths()) {
    CalciteSchema schema =
        getSchema(catalogReader.getRootSchema(),
            Iterables.concat(schemaPath, Util.skipLast(names)),
            catalogReader.nameMatcher());
    if (schema == null) {
      continue;
    }
    CalciteSchema.TableEntry entry =
        getTableEntryFrom(schema, Util.last(names),
            catalogReader.nameMatcher().isCaseSensitive());
    if (entry != null) {
      return entry;
    }
  }
  return null;
}
 
开发者ID:apache,项目名称:calcite,代码行数:35,代码来源:SqlValidatorUtil.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MessageType类代码示例发布时间:2022-05-22
下一篇:
Java Buffer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap