本文整理汇总了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;
}
示例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);
}
示例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();
}
示例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);
}
}
示例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()
);
}
示例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<>();
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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));
}
示例14: BeamSqlEnv
import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
public BeamSqlEnv() {
schema = Frameworks.createRootSchema(true);
planner = new BeamQueryPlanner(schema);
}
示例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);
}