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


Java Frameworks.createRootSchema方法代码示例

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


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

示例1: getRootSchema

import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
private SchemaPlus getRootSchema() throws MetadataStorageManagerException {
    if (rootSchema != null) {
        return rootSchema;
    }
    final SchemaPlus _rootSchema = Frameworks.createRootSchema(true);
    for (String tableSpace : manager.getLocalTableSpaces()) {
        TableSpaceManager tableSpaceManager = manager.getTableSpaceManager(tableSpace);
        SchemaPlus schema = _rootSchema.add(tableSpace, new AbstractSchema());
        List<Table> tables = tableSpaceManager.getAllTablesForPlanner();
        for (Table table : tables) {
            AbstractTableManager tableManager = tableSpaceManager.getTableManager(table.name);
            TableImpl tableDef = new TableImpl(tableManager);
            schema.add(table.name, tableDef);
        }
    }
    rootSchema = _rootSchema;
    return _rootSchema;
}
 
开发者ID:diennea,项目名称:herddb,代码行数:19,代码来源:CalcitePlanner.java

示例2: prepare

import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
@BeforeClass
public static void prepare() {
  relDataType = TYPE_FACTORY.builder()
      .add("order_id", SqlTypeName.BIGINT)
      .add("site_id", SqlTypeName.INTEGER)
      .add("price", SqlTypeName.DOUBLE)
      .add("order_time", SqlTypeName.BIGINT).build();

  beamRowType = CalciteUtils.toBeamRowType(relDataType);
  record = new BeamRecord(beamRowType
      , 1234567L, 0, 8.9, 1234567L);

  SchemaPlus schema = Frameworks.createRootSchema(true);
  final List<RelTraitDef> traitDefs = new ArrayList<>();
  traitDefs.add(ConventionTraitDef.INSTANCE);
  traitDefs.add(RelCollationTraitDef.INSTANCE);
  FrameworkConfig config = Frameworks.newConfigBuilder()
      .parserConfig(SqlParser.configBuilder().setLex(Lex.MYSQL).build()).defaultSchema(schema)
      .traitDefs(traitDefs).context(Contexts.EMPTY_CONTEXT).ruleSets(BeamRuleSets.getRuleSets())
      .costFactory(null).typeSystem(BeamRelDataTypeSystem.BEAM_REL_DATATYPE_SYSTEM).build();

  relBuilder = RelBuilder.create(config);
}
 
开发者ID:apache,项目名称:beam,代码行数:24,代码来源:BeamSqlFnExecutorTestBase.java

示例3: GremlinCompiler

import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
public GremlinCompiler(Graph graph, SchemaConfig schemaConfig) {
    this.graph = graph;
    this.schemaConfig = schemaConfig;

    final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
    final List<RelTraitDef> traitDefs = new ArrayList<>();
    traitDefs.add(ConventionTraitDef.INSTANCE);
    traitDefs.add(RelCollationTraitDef.INSTANCE);
    final SqlParser.Config parserConfig =
            SqlParser.configBuilder().setLex(Lex.MYSQL).build();

    frameworkConfig = Frameworks.newConfigBuilder()
            .parserConfig(parserConfig)
            .defaultSchema(rootSchema.add("gremlin", new GremlinSchema(graph, schemaConfig)))
            .traitDefs(traitDefs)
            .programs(Programs.sequence(Programs.ofRules(Programs.RULE_SET), Programs.CALC_PROGRAM))
            .build();
}
 
开发者ID:twilmes,项目名称:sql-gremlin,代码行数:19,代码来源:GremlinCompiler.java

示例4: parse

import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
public void parse() {
    try {
        SchemaPlus schema = Frameworks.createRootSchema(true);
        FrameworkConfig config = Frameworks.newConfigBuilder().defaultSchema(schema).build();
        Planner planner = Frameworks.getPlanner(config);
        SqlSelect sqlSelect = (SqlSelect) planner.parse(sql);
        // FROM
        streams = parseStreams(sqlSelect);
        // SELECT
        projection = parseProjection(sqlSelect);
        // WHERE
        condition = parseCondition(sqlSelect);
        // GROUP BY
        groupBy = parseGroupBy(sqlSelect);
        // HAVING
        having = parseHaving(sqlSelect);
    } catch (Exception ex) {
        LOG.error("Got Exception while parsing rule {}", sql);
        throw new RuntimeException(ex);
    }
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:22,代码来源:RuleParser.java

示例5: getBuilder

import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
/**
 * Creates a {@link RelBuilder} with the given schema.
 *
 * @param dataSource  The dataSource for the jdbc schema.
 * @param schemaName  The name of the schema used for the database.
 *
 * @return the relbuilder from Calcite.
 *
 * @throws SQLException if can't readSqlResultSet from database.
 */
public static RelBuilder getBuilder(DataSource dataSource, String schemaName) throws SQLException {
    SchemaPlus rootSchema = Frameworks.createRootSchema(true);
    return RelBuilder.create(
            Frameworks.newConfigBuilder()
                    .parserConfig(SqlParser.Config.DEFAULT)
                    .defaultSchema(addSchema(rootSchema, dataSource, schemaName))
                    .traitDefs((List<RelTraitDef>) null)
                    .programs(Programs.heuristicJoinOrder(Programs.RULE_SET, true, 2))
                    .build()
    );
}
 
开发者ID:yahoo,项目名称:fili,代码行数:22,代码来源:CalciteHelper.java

示例6: SchemaManager

import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
private SchemaManager(MetaStore metaStore) {
    super(SchemaManager.class.getName());

    this.metaStore = metaStore;
    rootSchema = Frameworks.createRootSchema(false);

    dataSourceMap = new HashMap<>();
    schemaMap = new HashMap<>();
    tableMap = new HashMap<>();
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:11,代码来源:SchemaManager.java

示例7: sqlOverDummyTable

import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
public static CalciteState sqlOverDummyTable(String sql)
        throws RelConversionException, ValidationException, SqlParseException {
    SchemaPlus schema = Frameworks.createRootSchema(true);
    JavaTypeFactory typeFactory = new JavaTypeFactoryImpl
            (RelDataTypeSystem.DEFAULT);
    StreamableTable streamableTable = new CompilerUtil.TableBuilderInfo(typeFactory)
            .field("ID", SqlTypeName.INTEGER)
            .field("NAME", typeFactory.createType(String.class))
            .field("ADDR", typeFactory.createType(String.class))
            .build();
    Table table = streamableTable.stream();
    schema.add("FOO", table);
    schema.add("BAR", table);
    schema.add("MYPLUS", ScalarFunctionImpl.create(MyPlus.class, "eval"));

    List<SqlOperatorTable> sqlOperatorTables = new ArrayList<>();
    sqlOperatorTables.add(SqlStdOperatorTable.instance());
    sqlOperatorTables.add(new CalciteCatalogReader(CalciteSchema.from(schema),
            false,
            Collections.<String>emptyList(), typeFactory));
    SqlOperatorTable chainedSqlOperatorTable = new ChainedSqlOperatorTable(sqlOperatorTables);
    FrameworkConfig config = Frameworks.newConfigBuilder().defaultSchema(
            schema).operatorTable(chainedSqlOperatorTable).build();
    Planner planner = Frameworks.getPlanner(config);
    SqlNode parse = planner.parse(sql);
    SqlNode validate = planner.validate(parse);
    RelNode tree = planner.convert(validate);
    System.out.println(RelOptUtil.toString(tree, SqlExplainLevel.ALL_ATTRIBUTES));
    return new CalciteState(schema, tree);
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:31,代码来源:TestCompilerUtils.java

示例8: createTestSchema

import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
private SchemaPlus createTestSchema() {
  SchemaPlus result = Frameworks.createRootSchema(false);
  result.add("t",
      new PigTable("target/data.txt",
      new String[] { "tc0", "tc1" }));
  result.add("s",
      new PigTable("target/data2.txt",
      new String[] { "sc0", "sc1" }));
  return result;
}
 
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:PigRelBuilderStyleTest.java

示例9: getPlanner

import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
private static Planner getPlanner(List<RelTraitDef> traitDefs,
    SqlParser.Config parserConfig, CalciteAssert.SchemaSpec schemaSpec,
    SqlToRelConverter.Config sqlToRelConf, Program... programs) {
  final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
  final FrameworkConfig config = Frameworks.newConfigBuilder()
      .parserConfig(parserConfig)
      .defaultSchema(CalciteAssert.addSchema(rootSchema, schemaSpec))
      .traitDefs(traitDefs)
      .sqlToRelConverterConfig(sqlToRelConf)
      .programs(programs)
      .build();
  return Frameworks.getPlanner(config);
}
 
开发者ID:apache,项目名称:calcite,代码行数:14,代码来源:RelToSqlConverterTest.java

示例10: getPlanner

import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
private static Planner getPlanner(List<RelTraitDef> traitDefs,
    SqlParser.Config parserConfig, Program... programs) {
  final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
  final FrameworkConfig config = Frameworks.newConfigBuilder()
      .parserConfig(parserConfig)
      .defaultSchema(CalciteAssert.addSchema(rootSchema, CalciteAssert.SchemaSpec.HR))
      .traitDefs(traitDefs)
      .programs(programs)
      .build();
  return Frameworks.getPlanner(config);
}
 
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:LexCaseSensitiveTest.java

示例11: setUp

import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
@Before public void setUp() {
  rootSchema = Frameworks.createRootSchema(true);
  final FrameworkConfig config = Frameworks.newConfigBuilder()
      .parserConfig(SqlParser.Config.DEFAULT)
      .defaultSchema(
          CalciteAssert.addSchema(rootSchema, CalciteAssert.SchemaSpec.HR))
      .build();
  planner = Frameworks.getPlanner(config);
  dataContext = new MyDataContext(planner);
}
 
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:InterpreterTest.java

示例12: config

import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
/** Creates a config based on the "scott" schema. */
public static Frameworks.ConfigBuilder config() {
  final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
  return Frameworks.newConfigBuilder()
      .parserConfig(SqlParser.Config.DEFAULT)
      .defaultSchema(
          CalciteAssert.addSchema(rootSchema, CalciteAssert.SchemaSpec.SCOTT))
      .traitDefs((List<RelTraitDef>) null)
      .programs(Programs.heuristicJoinOrder(Programs.RULE_SET, true, 2));
}
 
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:RelBuilderTest.java

示例13: config

import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
/** Creates a config based on the "scott" schema. */
private static Frameworks.ConfigBuilder config() {
  final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
  return Frameworks.newConfigBuilder()
      .parserConfig(SqlParser.Config.DEFAULT)
      .defaultSchema(CalciteAssert.addSchema(rootSchema, CalciteAssert.SchemaSpec.SCOTT));
}
 
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:RelOptUtilTest.java

示例14: BeamSqlEnv

import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
public BeamSqlEnv() {
  schema = Frameworks.createRootSchema(true);
  planner = new BeamQueryPlanner(schema);
}
 
开发者ID:apache,项目名称:beam,代码行数:5,代码来源:BeamSqlEnv.java

示例15: sqlOverNestedTable

import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
public static CalciteState sqlOverNestedTable(String sql)
        throws RelConversionException, ValidationException, SqlParseException {
    SchemaPlus schema = Frameworks.createRootSchema(true);
    JavaTypeFactory typeFactory = new JavaTypeFactoryImpl
            (RelDataTypeSystem.DEFAULT);

    StreamableTable streamableTable = new CompilerUtil.TableBuilderInfo(typeFactory)
            .field("ID", SqlTypeName.INTEGER)
            .field("MAPFIELD",
                    typeFactory.createTypeWithNullability(
                            typeFactory.createMapType(
                                    typeFactory.createTypeWithNullability(
                                            typeFactory.createSqlType(SqlTypeName.VARCHAR), true),
                                    typeFactory.createTypeWithNullability(
                                            typeFactory.createSqlType(SqlTypeName.INTEGER), true))
                            , true))
            .field("NESTEDMAPFIELD",
                    typeFactory.createTypeWithNullability(
                        typeFactory.createMapType(
                                typeFactory.createTypeWithNullability(
                                        typeFactory.createSqlType(SqlTypeName.VARCHAR), true),
                                typeFactory.createTypeWithNullability(
                                        typeFactory.createMapType(
                                                typeFactory.createTypeWithNullability(
                                                        typeFactory.createSqlType(SqlTypeName.VARCHAR), true),
                                                typeFactory.createTypeWithNullability(
                                                        typeFactory.createSqlType(SqlTypeName.INTEGER), true))
                                        , true))
                                    , true))
            .field("ARRAYFIELD", typeFactory.createTypeWithNullability(
                    typeFactory.createArrayType(
                        typeFactory.createTypeWithNullability(
                            typeFactory.createSqlType(SqlTypeName.INTEGER), true), -1L)
                    , true))
            .build();
    Table table = streamableTable.stream();
    schema.add("FOO", table);
    schema.add("BAR", table);
    schema.add("MYPLUS", ScalarFunctionImpl.create(MyPlus.class, "eval"));
    List<SqlOperatorTable> sqlOperatorTables = new ArrayList<>();
    sqlOperatorTables.add(SqlStdOperatorTable.instance());
    sqlOperatorTables.add(new CalciteCatalogReader(CalciteSchema.from(schema),
                                                   false,
                                                   Collections.<String>emptyList(), typeFactory));
    SqlOperatorTable chainedSqlOperatorTable = new ChainedSqlOperatorTable(sqlOperatorTables);
    FrameworkConfig config = Frameworks.newConfigBuilder().defaultSchema(
            schema).operatorTable(chainedSqlOperatorTable).build();
    Planner planner = Frameworks.getPlanner(config);
    SqlNode parse = planner.parse(sql);
    SqlNode validate = planner.validate(parse);
    RelNode tree = planner.convert(validate);
    System.out.println(RelOptUtil.toString(tree, SqlExplainLevel.ALL_ATTRIBUTES));
    return new CalciteState(schema, tree);
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:55,代码来源:TestCompilerUtils.java


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