本文整理汇总了Java中org.apache.calcite.sql.parser.SqlParser.Config方法的典型用法代码示例。如果您正苦于以下问题:Java SqlParser.Config方法的具体用法?Java SqlParser.Config怎么用?Java SqlParser.Config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.sql.parser.SqlParser
的用法示例。
在下文中一共展示了SqlParser.Config方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GremlinCompiler
import org.apache.calcite.sql.parser.SqlParser; //导入方法依赖的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();
}
示例2: StdFrameworkConfig
import org.apache.calcite.sql.parser.SqlParser; //导入方法依赖的package包/类
StdFrameworkConfig(Context context,
SqlRexConvertletTable convertletTable,
SqlOperatorTable operatorTable,
ImmutableList<Program> programs,
ImmutableList<RelTraitDef> traitDefs,
SqlParser.Config parserConfig,
SqlToRelConverter.Config sqlToRelConverterConfig,
SchemaPlus defaultSchema,
RelOptCostFactory costFactory,
RelDataTypeSystem typeSystem,
RexExecutor executor) {
this.context = context;
this.convertletTable = convertletTable;
this.operatorTable = operatorTable;
this.programs = programs;
this.traitDefs = traitDefs;
this.parserConfig = parserConfig;
this.sqlToRelConverterConfig = sqlToRelConverterConfig;
this.defaultSchema = defaultSchema;
this.costFactory = costFactory;
this.typeSystem = typeSystem;
this.executor = executor;
}
示例3: testUpdate
import org.apache.calcite.sql.parser.SqlParser; //导入方法依赖的package包/类
/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-2039">[CALCITE-2039]
* AssertionError when pushing project to ProjectableFilterableTable</a>
* using UPDATE via {@link Frameworks}. */
@Test public void testUpdate() throws Exception {
Table table = new TableImpl();
final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
SchemaPlus schema = rootSchema.add("x", new AbstractSchema());
schema.add("MYTABLE", table);
List<RelTraitDef> traitDefs = new ArrayList<>();
traitDefs.add(ConventionTraitDef.INSTANCE);
traitDefs.add(RelDistributionTraitDef.INSTANCE);
SqlParser.Config parserConfig =
SqlParser.configBuilder(SqlParser.Config.DEFAULT)
.setCaseSensitive(false)
.build();
final FrameworkConfig config = Frameworks.newConfigBuilder()
.parserConfig(parserConfig)
.defaultSchema(schema)
.traitDefs(traitDefs)
// define the rules you want to apply
.ruleSets(
RuleSets.ofList(AbstractConverter.ExpandConversionRule.INSTANCE))
.programs(Programs.ofRules(Programs.RULE_SET))
.build();
executeQuery(config, " UPDATE MYTABLE set id=7 where id=1",
CalcitePrepareImpl.DEBUG);
}
示例4: storeQueryResultsIfNeeded
import org.apache.calcite.sql.parser.SqlParser; //导入方法依赖的package包/类
/**
* When enabled, add a writer rel on top of the given rel to catch the output and write to configured store table.
* @param inputRel
* @return
*/
public static Rel storeQueryResultsIfNeeded(final SqlParser.Config config, final QueryContext context,
final Rel inputRel) {
final OptionManager options = context.getOptions();
final boolean storeResults = options.getOption(STORE_QUERY_RESULTS.getOptionName()) != null ?
options.getOption(STORE_QUERY_RESULTS.getOptionName()).bool_val : false;
if (!storeResults) {
return inputRel;
}
// store query results as the system user
final SchemaPlus systemUserSchema = context.getRootSchema(
SchemaConfig.newBuilder(SystemUser.SYSTEM_USERNAME)
.setProvider(context.getSchemaInfoProvider())
.build());
final String storeTablePath = options.getOption(QUERY_RESULTS_STORE_TABLE.getOptionName()).string_val;
final List<String> storeTable =
new StrTokenizer(storeTablePath, '.', config.quoting().string.charAt(0))
.setIgnoreEmptyTokens(true)
.getTokenList();
final AbstractSchema schema = SchemaUtilities.resolveToMutableSchemaInstance(systemUserSchema,
Util.skipLast(storeTable), true, MutationType.TABLE);
// Query results are stored in arrow format. If need arises, we can change this to a configuration option.
final Map<String, Object> storageOptions = ImmutableMap.<String, Object>of("type", ArrowFormatPlugin.ARROW_DEFAULT_NAME);
final CreateTableEntry createTableEntry = schema.createNewTable(Util.last(storeTable), WriterOptions.DEFAULT, storageOptions);
final RelTraitSet traits = inputRel.getCluster().traitSet().plus(Rel.LOGICAL);
return new WriterRel(inputRel.getCluster(), traits, inputRel, createTableEntry, inputRel.getRowType());
}
示例5: getPlanner
import org.apache.calcite.sql.parser.SqlParser; //导入方法依赖的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);
}
示例6: getPlanner
import org.apache.calcite.sql.parser.SqlParser; //导入方法依赖的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);
}
示例7: getPlanner
import org.apache.calcite.sql.parser.SqlParser; //导入方法依赖的package包/类
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);
}
示例8: testOrderByNonSelectColumn
import org.apache.calcite.sql.parser.SqlParser; //导入方法依赖的package包/类
/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-569">[CALCITE-569]
* ArrayIndexOutOfBoundsException when deducing collation</a>. */
@Test public void testOrderByNonSelectColumn() throws Exception {
final SchemaPlus schema = Frameworks.createRootSchema(true)
.add("tpch", new ReflectiveSchema(new TpchSchema()));
String query = "select t.psPartkey from \n"
+ "(select ps.psPartkey from `tpch`.`partsupp` ps \n"
+ "order by ps.psPartkey, ps.psSupplyCost) t \n"
+ "order by t.psPartkey";
List<RelTraitDef> traitDefs = new ArrayList<>();
traitDefs.add(ConventionTraitDef.INSTANCE);
traitDefs.add(RelCollationTraitDef.INSTANCE);
final SqlParser.Config parserConfig =
SqlParser.configBuilder().setLex(Lex.MYSQL).build();
FrameworkConfig config = Frameworks.newConfigBuilder()
.parserConfig(parserConfig)
.defaultSchema(schema)
.traitDefs(traitDefs)
.programs(Programs.ofRules(Programs.RULE_SET))
.build();
String plan;
try (Planner p = Frameworks.getPlanner(config)) {
SqlNode n = p.parse(query);
n = p.validate(n);
RelNode r = p.rel(n).project();
plan = RelOptUtil.toString(r);
plan = Util.toLinux(plan);
}
assertThat(plan,
equalTo("LogicalSort(sort0=[$0], dir0=[ASC])\n"
+ " LogicalProject(psPartkey=[$0])\n"
+ " LogicalProject(psPartkey=[$0])\n"
+ " LogicalSort(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC])\n"
+ " LogicalProject(psPartkey=[$0], psSupplyCost=[$1])\n"
+ " EnumerableTableScan(table=[[tpch, partsupp]])\n"));
}
示例9: getParserConfig
import org.apache.calcite.sql.parser.SqlParser; //导入方法依赖的package包/类
public SqlParser.Config getParserConfig() {
return parserConfig;
}
示例10: getParserConfig
import org.apache.calcite.sql.parser.SqlParser; //导入方法依赖的package包/类
/**
* The configuration of SQL parser.
*/
SqlParser.Config getParserConfig();