本文整理了Java中org.apache.calcite.tools.Frameworks.getPlanner()
方法的一些代码示例,展示了Frameworks.getPlanner()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Frameworks.getPlanner()
方法的具体详情如下:
包路径:org.apache.calcite.tools.Frameworks
类名称:Frameworks
方法名:getPlanner
[英]Creates a planner.
[中]创建一个计划器。
代码示例来源:origin: apache/storm
public QueryPlanner(SchemaPlus schema) {
final List<RelTraitDef> traitDefs = new ArrayList<RelTraitDef>();
traitDefs.add(ConventionTraitDef.INSTANCE);
traitDefs.add(RelCollationTraitDef.INSTANCE);
List<SqlOperatorTable> sqlOperatorTables = new ArrayList<>();
sqlOperatorTables.add(SqlStdOperatorTable.instance());
sqlOperatorTables.add(new CalciteCatalogReader(CalciteSchema.from(schema),
Collections.emptyList(), typeFactory, new CalciteConnectionConfigImpl(new Properties())));
FrameworkConfig config = Frameworks.newConfigBuilder()
.defaultSchema(schema)
.operatorTable(new ChainedSqlOperatorTable(sqlOperatorTables))
.traitDefs(traitDefs)
.context(Contexts.EMPTY_CONTEXT)
.ruleSets(StreamsStormRuleSets.getRuleSets())
.costFactory(null)
.typeSystem(StormRelDataTypeSystem.STORM_REL_DATATYPE_SYSTEM)
.build();
this.planner = Frameworks.getPlanner(config);
}
代码示例来源:origin: apache/storm
public String explain(String query) throws SqlParseException, ValidationException, RelConversionException {
FrameworkConfig config = buildFrameWorkConfig();
Planner planner = Frameworks.getPlanner(config);
SqlNode parse = planner.parse(query);
SqlNode validate = planner.validate(parse);
RelNode tree = planner.convert(validate);
return StormRelUtils.explain(tree, SqlExplainLevel.ALL_ATTRIBUTES);
}
代码示例来源:origin: apache/incubator-druid
Frameworks.getPlanner(frameworkConfig),
plannerContext
);
代码示例来源:origin: twilmes/sql-gremlin
public QueryPlanner(final FrameworkConfig frameworkConfig) {
this.planner = Frameworks.getPlanner(frameworkConfig);
}
代码示例来源:origin: Qihoo360/Quicksql
RelNode createLogicalPlan(String sql) {
Planner planner = Frameworks.getPlanner(super.config);
try {
SqlNode parsed = planner.parse(sql);
SqlNode validated = planner.validate(parsed);
return planner.rel(validated).rel;
} catch (SqlParseException
| ValidationException
| RelConversionException ex) {
throw new RuntimeException(ex.getMessage());
}
}
}
代码示例来源:origin: Qihoo360/Quicksql
private RelNode buildLogicalPlan(String sql) {
Planner planner = Frameworks.getPlanner(config);
try {
SqlNode parsed = planner.parse(sql);
SqlNode validated = planner.validate(parsed);
return planner.rel(validated).rel;
} catch (SqlParseException ex) {
throw new ParseException("Error When Parsing Origin SQL: " + ex.getMessage(), ex);
} catch (ValidationException | RelConversionException ev) {
throw new ParseException("Error When Validating: " + ev.getMessage(), ev);
} catch (Throwable ex) {
throw new ParseException(
"Unknown Parse Exception, Concrete Message is: " + ex.getMessage());
}
}
代码示例来源:origin: Qihoo360/Quicksql
private RelNode buildLogicalPlan(String sql) {
Planner planner = Frameworks.getPlanner(config);
try {
SqlNode parsed = planner.parse(sql);
SqlNode validated = planner.validate(parsed);
return planner.rel(validated).rel;
} catch (SqlParseException ex) {
throw new ParseException("Error When Parsing Origin SQL: " + ex.getMessage(), ex);
} catch (ValidationException | RelConversionException ev) {
throw new ParseException("Error When Validating: " + ev.getMessage(), ev);
} catch (Throwable ex) {
throw new ParseException("Unknown Parse Exception, Concrete Message is: " + ex.getMessage());
}
}
代码示例来源:origin: org.apache.calcite/calcite-core
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);
}
代码示例来源:origin: org.apache.calcite/calcite-core
private 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);
}
代码示例来源:origin: Qihoo360/Quicksql
@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);
}
代码示例来源:origin: org.apache.calcite/calcite-core
private static Planner getPlanner(List<RelTraitDef> traitDefs,
SqlParser.Config parserConfig, SchemaPlus schema,
SqlToRelConverter.Config sqlToRelConf, Program... programs) {
final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
final FrameworkConfig config = Frameworks.newConfigBuilder()
.parserConfig(parserConfig)
.defaultSchema(schema)
.traitDefs(traitDefs)
.sqlToRelConverterConfig(sqlToRelConf)
.programs(programs)
.build();
return Frameworks.getPlanner(config);
}
代码示例来源:origin: Qihoo360/Quicksql
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);
}
代码示例来源:origin: org.apache.calcite/calcite-core
@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);
}
代码示例来源:origin: Qihoo360/Quicksql
private 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);
}
代码示例来源:origin: Qihoo360/Quicksql
private static Planner getPlanner(List<RelTraitDef> traitDefs,
SqlParser.Config parserConfig, SchemaPlus schema,
SqlToRelConverter.Config sqlToRelConf, Program... programs) {
final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
final FrameworkConfig config = Frameworks.newConfigBuilder()
.parserConfig(parserConfig)
.defaultSchema(schema)
.traitDefs(traitDefs)
.sqlToRelConverterConfig(sqlToRelConf)
.programs(programs)
.build();
return Frameworks.getPlanner(config);
}
代码示例来源:origin: org.apache.calcite/calcite-core
private void checkView(String sql, Matcher<String> matcher)
throws SqlParseException, ValidationException, RelConversionException {
final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
final FrameworkConfig config = Frameworks.newConfigBuilder()
.defaultSchema(
CalciteAssert.addSchema(rootSchema, CalciteAssert.SchemaSpec.POST))
.build();
final Planner planner = Frameworks.getPlanner(config);
SqlNode parse = planner.parse(sql);
final SqlNode validate = planner.validate(parse);
final RelRoot root = planner.rel(validate);
assertThat(toString(root.rel), matcher);
}
}
代码示例来源:origin: Qihoo360/Quicksql
/** Checks that a query returns a particular plan, using a planner with
* MultiJoinOptimizeBushyRule enabled. */
private void checkBushy(String sql, String expected) throws Exception {
final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
final FrameworkConfig config = Frameworks.newConfigBuilder()
.parserConfig(SqlParser.Config.DEFAULT)
.defaultSchema(
CalciteAssert.addSchema(rootSchema,
CalciteAssert.SchemaSpec.CLONE_FOODMART))
.traitDefs((List<RelTraitDef>) null)
.programs(Programs.heuristicJoinOrder(Programs.RULE_SET, true, 2))
.build();
Planner planner = Frameworks.getPlanner(config);
SqlNode parse = planner.parse(sql);
SqlNode validate = planner.validate(parse);
RelNode convert = planner.rel(validate).project();
RelTraitSet traitSet = planner.getEmptyTraitSet()
.replace(EnumerableConvention.INSTANCE);
RelNode transform = planner.transform(0, traitSet, convert);
assertThat(toString(transform), containsString(expected));
}
代码示例来源:origin: org.apache.calcite/calcite-core
/** Checks that a query returns a particular plan, using a planner with
* MultiJoinOptimizeBushyRule enabled. */
private void checkBushy(String sql, String expected) throws Exception {
final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
final FrameworkConfig config = Frameworks.newConfigBuilder()
.parserConfig(SqlParser.Config.DEFAULT)
.defaultSchema(
CalciteAssert.addSchema(rootSchema,
CalciteAssert.SchemaSpec.CLONE_FOODMART))
.traitDefs((List<RelTraitDef>) null)
.programs(Programs.heuristicJoinOrder(Programs.RULE_SET, true, 2))
.build();
Planner planner = Frameworks.getPlanner(config);
SqlNode parse = planner.parse(sql);
SqlNode validate = planner.validate(parse);
RelNode convert = planner.rel(validate).project();
RelTraitSet traitSet = planner.getEmptyTraitSet()
.replace(EnumerableConvention.INSTANCE);
RelNode transform = planner.transform(0, traitSet, convert);
assertThat(toString(transform), containsString(expected));
}
代码示例来源:origin: Qihoo360/Quicksql
public String checkTpchQuery(String tpchTestQuery) throws Exception {
final SchemaPlus schema =
Frameworks.createRootSchema(true).add("tpch",
new ReflectiveSchema(new TpchSchema()));
final FrameworkConfig config = Frameworks.newConfigBuilder()
.parserConfig(SqlParser.configBuilder().setLex(Lex.MYSQL).build())
.defaultSchema(schema)
.programs(Programs.ofRules(Programs.RULE_SET))
.build();
String plan;
try (Planner p = Frameworks.getPlanner(config)) {
SqlNode n = p.parse(tpchTestQuery);
n = p.validate(n);
RelNode r = p.rel(n).project();
plan = RelOptUtil.toString(r);
}
return plan;
}
代码示例来源:origin: org.apache.calcite/calcite-core
public String checkTpchQuery(String tpchTestQuery) throws Exception {
final SchemaPlus schema =
Frameworks.createRootSchema(true).add("tpch",
new ReflectiveSchema(new TpchSchema()));
final FrameworkConfig config = Frameworks.newConfigBuilder()
.parserConfig(SqlParser.configBuilder().setLex(Lex.MYSQL).build())
.defaultSchema(schema)
.programs(Programs.ofRules(Programs.RULE_SET))
.build();
String plan;
try (Planner p = Frameworks.getPlanner(config)) {
SqlNode n = p.parse(tpchTestQuery);
n = p.validate(n);
RelNode r = p.rel(n).project();
plan = RelOptUtil.toString(r);
}
return plan;
}
内容来源于网络,如有侵权,请联系作者删除!