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

Java Lex类代码示例

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

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



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

示例1: prepare

import org.apache.calcite.config.Lex; //导入依赖的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


示例2: GremlinCompiler

import org.apache.calcite.config.Lex; //导入依赖的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


示例3: createPlanner

import org.apache.calcite.config.Lex; //导入依赖的package包/类
private static Planner createPlanner() {
  Connection connection;
  SchemaPlus rootSchema;
  try {
    connection = DriverManager.getConnection("jdbc:calcite:");
    CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class);
    rootSchema = calciteConnection.getRootSchema();
  } catch (SQLException e) {
    throw new SamzaException(e);
  }

  final List<RelTraitDef> traitDefs = new ArrayList<>();

  traitDefs.add(ConventionTraitDef.INSTANCE);
  traitDefs.add(RelCollationTraitDef.INSTANCE);

  FrameworkConfig frameworkConfig = Frameworks.newConfigBuilder()
      .parserConfig(SqlParser.configBuilder().setLex(Lex.JAVA).build())
      .defaultSchema(rootSchema)
      .operatorTable(SqlStdOperatorTable.instance())
      .traitDefs(traitDefs)
      .context(Contexts.EMPTY_CONTEXT)
      .costFactory(null)
      .build();
  return Frameworks.getPlanner(frameworkConfig);
}
 
开发者ID:apache,项目名称:samza,代码行数:27,代码来源:SamzaSqlQueryParser.java


示例4: runProjectQueryWithLex

import org.apache.calcite.config.Lex; //导入依赖的package包/类
private static void runProjectQueryWithLex(Lex lex, String sql)
    throws SqlParseException, ValidationException, RelConversionException {
  Config javaLex = SqlParser.configBuilder().setLex(lex).build();
  Planner planner = getPlanner(null, javaLex, Programs.ofRules(Programs.RULE_SET));
  SqlNode parse = planner.parse(sql);
  SqlNode validate = planner.validate(parse);
  RelNode convert = planner.rel(validate).rel;
  RelTraitSet traitSet =
      planner.getEmptyTraitSet().replace(EnumerableConvention.INSTANCE);
  RelNode transform = planner.transform(0, traitSet, convert);
  assertThat(transform, instanceOf(EnumerableProject.class));
  List<String> fieldNames = transform.getRowType().getFieldNames();
  assertThat(fieldNames.size(), is(2));
  if (lex.caseSensitive) {
    assertThat(fieldNames.get(0), is("EMPID"));
    assertThat(fieldNames.get(1), is("empid"));
  } else {
    assertThat(fieldNames.get(0) + "-" + fieldNames.get(1),
        anyOf(is("EMPID-empid0"), is("EMPID0-empid")));
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:LexCaseSensitiveTest.java


示例5: runDuplicateSortCheck

import org.apache.calcite.config.Lex; //导入依赖的package包/类
private void runDuplicateSortCheck(String sql, String plan) throws Exception {
  RuleSet ruleSet =
      RuleSets.ofList(
          SortRemoveRule.INSTANCE,
          EnumerableRules.ENUMERABLE_PROJECT_RULE,
          EnumerableRules.ENUMERABLE_WINDOW_RULE,
          EnumerableRules.ENUMERABLE_SORT_RULE,
          ProjectToWindowRule.PROJECT);
  Planner planner = getPlanner(null,
      SqlParser.configBuilder().setLex(Lex.JAVA).build(),
      Programs.of(ruleSet));
  SqlNode parse = planner.parse(sql);
  SqlNode validate = planner.validate(parse);
  RelNode convert = planner.rel(validate).rel;
  RelTraitSet traitSet = planner.getEmptyTraitSet()
      .replace(EnumerableConvention.INSTANCE);
  if (traitSet.getTrait(RelCollationTraitDef.INSTANCE) == null) {
    // SortRemoveRule can only work if collation trait is enabled.
    return;
  }
  RelNode transform = planner.transform(0, traitSet, convert);
  assertThat(toString(transform), equalTo(plan));
}
 
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:PlannerTest.java


示例6: checkTpchQuery

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


示例7: testCorrelatedScalarSubQuery

import org.apache.calcite.config.Lex; //导入依赖的package包/类
/** Test case for
 * <a href="https://issues.apache.org/jira/browse/CALCITE-685">[CALCITE-685]
 * Correlated scalar sub-query in SELECT clause throws</a>. */
@Ignore("[CALCITE-685]")
@Test public void testCorrelatedScalarSubQuery() throws SQLException {
  final String sql = "select e.department_id, sum(e.employee_id),\n"
      + "       ( select sum(e2.employee_id)\n"
      + "         from  employee e2\n"
      + "         where e.department_id = e2.department_id\n"
      + "       )\n"
      + "from employee e\n"
      + "group by e.department_id\n";
  final String explain = "EnumerableJoin(condition=[true], joinType=[left])\n"
      + "  EnumerableAggregate(group=[{7}], EXPR$1=[$SUM0($0)])\n"
      + "    EnumerableTableScan(table=[[foodmart2, employee]])\n"
      + "  EnumerableAggregate(group=[{}], EXPR$0=[SUM($0)])\n"
      + "    EnumerableCalc(expr#0..16=[{inputs}], expr#17=[$cor0], expr#18=[$t17.department_id], expr#19=[=($t18, $t7)], employee_id=[$t0], department_id=[$t7], $condition=[$t19])\n"
      + "      EnumerableTableScan(table=[[foodmart2, employee]])\n";
  CalciteAssert.that()
      .with(CalciteAssert.Config.FOODMART_CLONE)
      .with(Lex.JAVA)
      .query(sql)
      .explainContains(explain)
      .returnsCount(0);
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:JdbcTest.java


示例8: testLexCaseInsensitive

import org.apache.calcite.config.Lex; //导入依赖的package包/类
/** Tests case-insensitive resolution of schema and table names. */
@Test public void testLexCaseInsensitive() {
  final CalciteAssert.AssertThat with =
      CalciteAssert.that().with(Lex.MYSQL);
  with.query("select COUNT(*) as c from metaData.tAbles")
      .returns("c=2\n");
  with.query("select COUNT(*) as c from `metaData`.`tAbles`")
      .returns("c=2\n");

  // case-sensitive gives error
  final CalciteAssert.AssertThat with2 =
      CalciteAssert.that().with(Lex.JAVA);
  with2.query("select COUNT(*) as c from `metaData`.`tAbles`")
      .throws_("Object 'metaData' not found; did you mean 'metadata'?");
  with2.query("select COUNT(*) as c from `metaData`.`TABLES`")
      .throws_("Object 'metaData' not found; did you mean 'metadata'?");
  with2.query("select COUNT(*) as c from `metaData`.`tables`")
      .throws_("Object 'metaData' not found; did you mean 'metadata'?");
  with2.query("select COUNT(*) as c from `metaData`.`nonExistent`")
      .throws_("Object 'metaData' not found; did you mean 'metadata'?");
  with2.query("select COUNT(*) as c from `metadata`.`tAbles`")
      .throws_("Object 'tAbles' not found within 'metadata'; did you mean 'TABLES'?");
}
 
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:JdbcTest.java


示例9: testUnquotedCaseSensitiveSubQueryMySql

import org.apache.calcite.config.Lex; //导入依赖的package包/类
@Test public void testUnquotedCaseSensitiveSubQueryMySql() {
  final CalciteAssert.AssertThat with =
      CalciteAssert.that()
          .with(Lex.MYSQL);

  with.query("select DID from (select deptid as did FROM\n"
      + "     ( values (1), (2) ) as T1(deptid) ) ")
      .returnsUnordered("DID=1", "DID=2");

  with.query("select x.DID from (select deptid as did FROM\n"
      + "     ( values (1), (2) ) as T1(deptid) ) X ")
      .returnsUnordered("DID=1", "DID=2");

  with.query("select X.DID from (select deptid as did FROM\n"
      + "     ( values (1), (2) ) as T1(deptid) ) X ")
      .returnsUnordered("DID=1", "DID=2");

  with.query("select X.DID2 from (select deptid as did FROM\n"
      + "     ( values (1), (2) ) as T1(deptid) ) X (DID2)")
      .returnsUnordered("DID2=1", "DID2=2");

  with.query("select X.DID2 from (select deptid as did FROM\n"
      + "     ( values (1), (2) ) as T1(deptid) ) X (DID2)")
      .returnsUnordered("DID2=1", "DID2=2");
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:JdbcTest.java


示例10: testQuotedCaseSensitiveSubQueryMySql

import org.apache.calcite.config.Lex; //导入依赖的package包/类
@Test public void testQuotedCaseSensitiveSubQueryMySql() {
  final CalciteAssert.AssertThat with =
      CalciteAssert.that()
          .with(Lex.MYSQL);

  with.query("select `DID` from (select deptid as did FROM\n"
      + "     ( values (1), (2) ) as T1(deptid) ) ")
      .returnsUnordered("DID=1", "DID=2");

  with.query("select `x`.`DID` from (select deptid as did FROM\n"
      + "     ( values (1), (2) ) as T1(deptid) ) X ")
      .returnsUnordered("DID=1", "DID=2");

  with.query("select `X`.`DID` from (select deptid as did FROM\n"
      + "     ( values (1), (2) ) as T1(deptid) ) X ")
      .returnsUnordered("DID=1", "DID=2");

  with.query("select `X`.`DID2` from (select deptid as did FROM\n"
      + "     ( values (1), (2) ) as T1(deptid) ) X (DID2)")
      .returnsUnordered("DID2=1", "DID2=2");

  with.query("select `X`.`DID2` from (select deptid as did FROM\n"
      + "     ( values (1), (2) ) as T1(deptid) ) X (DID2)")
      .returnsUnordered("DID2=1", "DID2=2");
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:JdbcTest.java


示例11: testAvgInt

import org.apache.calcite.config.Lex; //导入依赖的package包/类
/** Test case for
 * <a href="https://issues.apache.org/jira/browse/CALCITE-580">[CALCITE-580]
 * Average aggregation on an Integer column throws ClassCastException</a>. */
@Test public void testAvgInt() throws Exception {
  CalciteAssert.that().withSchema("s", CATCHALL).with(Lex.JAVA)
      .query("select primitiveLong, avg(primitiveInt)\n"
              + "from s.everyTypes\n"
              + "group by primitiveLong order by primitiveLong")
      .returns(
          new Function<ResultSet, Void>() {
            public Void apply(ResultSet input) {
              StringBuilder buf = new StringBuilder();
              try {
                while (input.next()) {
                  buf.append(input.getInt(2)).append("\n");
                }
              } catch (SQLException e) {
                throw new RuntimeException(e);
              }
              assertThat(buf.toString(), equalTo("0\n2147483647\n"));
              return null;
            }
          });
}
 
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:ReflectiveSchemaTest.java


示例12: parse

import org.apache.calcite.config.Lex; //导入依赖的package包/类
@VisibleForTesting
static SqlNodeList parse(String sql) throws ParseException {
  // Keep the SQL syntax consistent with Flink
  try (StringReader in = new StringReader(sql)) {
    SqlParserImpl impl = new SqlParserImpl(in);

    // back tick as the quote
    impl.switchTo("BTID");
    impl.setTabSize(1);
    impl.setQuotedCasing(Lex.JAVA.quotedCasing);
    impl.setUnquotedCasing(Lex.JAVA.unquotedCasing);
    impl.setIdentifierMaxLength(DEFAULT_IDENTIFIER_MAX_LENGTH);
    return impl.SqlStmtsEof();
  }
}
 
开发者ID:uber,项目名称:AthenaX,代码行数:16,代码来源:Planner.java


示例13: DrillSqlWorker

import org.apache.calcite.config.Lex; //导入依赖的package包/类
public DrillSqlWorker(QueryContext context) {
  final List<RelTraitDef> traitDefs = new ArrayList<RelTraitDef>();

  traitDefs.add(ConventionTraitDef.INSTANCE);
  traitDefs.add(DrillDistributionTraitDef.INSTANCE);
  traitDefs.add(RelCollationTraitDef.INSTANCE);
  this.context = context;
  RelOptCostFactory costFactory = (context.getPlannerSettings().useDefaultCosting()) ?
      null : new DrillCostBase.DrillCostFactory() ;
  int idMaxLength = (int)context.getPlannerSettings().getIdentifierMaxLength();

  FrameworkConfig config = Frameworks.newConfigBuilder() //
      .parserConfig(SqlParser.configBuilder()
          .setLex(Lex.MYSQL)
          .setIdentifierMaxLength(idMaxLength)
          .setParserFactory(DrillParserWithCompoundIdConverter.FACTORY)
          .build()) //
      .defaultSchema(context.getNewDefaultSchema()) //
      .operatorTable(context.getDrillOperatorTable()) //
      .traitDefs(traitDefs) //
      .convertletTable(new DrillConvertletTable()) //
      .context(context.getPlannerSettings()) //
      .ruleSets(getRules(context)) //
      .costFactory(costFactory) //
      .executor(new DrillConstExecutor(context.getFunctionRegistry(), context, context.getPlannerSettings()))
      .typeSystem(DrillRelDataTypeSystem.DRILL_REL_DATATYPE_SYSTEM) //
      .build();
  this.planner = Frameworks.getPlanner(config);
  HepProgramBuilder builder = new HepProgramBuilder();
  builder.addRuleClass(ReduceExpressionsRule.class);
  builder.addRuleClass(ProjectToWindowRule.class);
  this.hepPlanner = new HepPlanner(builder.build());
  hepPlanner.addRule(ReduceExpressionsRule.CALC_INSTANCE);
  hepPlanner.addRule(ProjectToWindowRule.PROJECT);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:36,代码来源:DrillSqlWorker.java


示例14: checkComplexExpressionParsing

import org.apache.calcite.config.Lex; //导入依赖的package包/类
@Test
public void checkComplexExpressionParsing() throws Exception{
  FrameworkConfig config = Frameworks.newConfigBuilder() //
      .parserConfig(SqlParser.configBuilder()
          .setLex(Lex.MYSQL)
          .setIdentifierMaxLength(PlannerSettings.DEFAULT_IDENTIFIER_MAX_LENGTH)
          .setParserFactory(DrillParserImpl.FACTORY)
          .build()) //
      .defaultSchema(SimpleCalciteSchema.createRootSchema(false)) //
      .convertletTable(new DrillConvertletTable()) //
      .build();
  Planner planner = Frameworks.getPlanner(config);

  SqlNode node = planner.parse(""
      + "select a[4].c \n"
      + "from x.y.z \n"
      + "where a.c.b = 5 and x[2] = 7 \n"
      + "group by d \n"
      + "having a.c < 5 \n"
      + "order by x.a.a.a.a.a");

  String expected = "SELECT `a`[4]['c']\n" +
      "FROM `x`.`y`.`z`\n" +
      "WHERE `a`.`c`['b'] = 5 AND `x`[2] = 7\n" +
      "GROUP BY `d`\n" +
      "HAVING `a`.`c` < 5\n" +
      "ORDER BY `x`.`a`['a']['a']['a']['a']";


  SqlNode rewritten = node.accept(new CompoundIdentifierConverter());
  String rewrittenQuery = rewritten.toString();

  DrillAssert.assertMultiLineStringEquals(expected, rewrittenQuery);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:35,代码来源:TestSqlBracketlessSyntax.java


示例15: checkComplexExpressionParsing

import org.apache.calcite.config.Lex; //导入依赖的package包/类
@Test
public void checkComplexExpressionParsing() throws Exception{
  FrameworkConfig config = Frameworks.newConfigBuilder()
      .parserConfig(SqlParser.configBuilder()
          .setLex(Lex.MYSQL)
          .setIdentifierMaxLength(PlannerSettings.DEFAULT_IDENTIFIER_MAX_LENGTH)
          .setParserFactory(ParserImpl.FACTORY)
          .build())
      .defaultSchema(CalciteSchema.createRootSchema(false /* addMetadata */, false /* cache */).plus())
      .convertletTable(ConvertletTable.INSTANCE)
      .build();
  Planner planner = Frameworks.getPlanner(config);

  SqlNode node = planner.parse(""
      + "select a[4].c \n"
      + "from x.y.z \n"
      + "where a.c.b = 5 and x[2] = 7 \n"
      + "group by d \n"
      + "having a.c < 5 \n"
      + "order by x.a.a.a.a.a");

  String expected = "SELECT `a`[4]['c']\n" +
      "FROM `x`.`y`.`z`\n" +
      "WHERE `a`.`c`['b'] = 5 AND `x`[2] = 7\n" +
      "GROUP BY `d`\n" +
      "HAVING `a`.`c` < 5\n" +
      "ORDER BY `x`.`a`['a']['a']['a']['a']";


  SqlNode rewritten = node.accept(new CompoundIdentifierConverter());
  String rewrittenQuery = rewritten.toString();

  DremioAssert.assertMultiLineStringEquals(expected, rewrittenQuery);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:35,代码来源:TestSqlBracketlessSyntax.java


示例16: BeamSqlParser

import org.apache.calcite.config.Lex; //导入依赖的package包/类
public BeamSqlParser(String s) {
  this.impl = new BeamSqlParserImpl(new StringReader(s));
  this.impl.setTabSize(1);
  this.impl.setQuotedCasing(Lex.ORACLE.quotedCasing);
  this.impl.setUnquotedCasing(Lex.ORACLE.unquotedCasing);
  this.impl.setIdentifierMaxLength(DEFAULT_IDENTIFIER_MAX_LENGTH);
  /*
   *  By default parser uses [ ] for quoting identifiers. Switching to
   *  DQID (double quoted identifiers) is needed for array and map access
   *  (m['x'] = 1 or arr[2] = 10 etc) to work.
   */
  this.impl.switchTo("DQID");
}
 
开发者ID:apache,项目名称:beam,代码行数:14,代码来源:BeamSqlParser.java


示例17: BeamQueryPlanner

import org.apache.calcite.config.Lex; //导入依赖的package包/类
public BeamQueryPlanner(SchemaPlus schema) {
  String defaultCharsetKey = "saffron.default.charset";
  if (System.getProperty(defaultCharsetKey) == null) {
    System.setProperty(defaultCharsetKey, ConversionUtil.NATIVE_UTF16_CHARSET_NAME);
    System.setProperty("saffron.default.nationalcharset",
      ConversionUtil.NATIVE_UTF16_CHARSET_NAME);
    System.setProperty("saffron.default.collation.name",
      String.format("%s$%s", ConversionUtil.NATIVE_UTF16_CHARSET_NAME, "en_US"));
  }

  final List<RelTraitDef> traitDefs = new ArrayList<>();
  traitDefs.add(ConventionTraitDef.INSTANCE);
  traitDefs.add(RelCollationTraitDef.INSTANCE);

  List<SqlOperatorTable> sqlOperatorTables = new ArrayList<>();
  sqlOperatorTables.add(SqlStdOperatorTable.instance());
  sqlOperatorTables.add(new CalciteCatalogReader(CalciteSchema.from(schema), false,
      Collections.<String>emptyList(), TYPE_FACTORY));

  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)
      .operatorTable(new ChainedSqlOperatorTable(sqlOperatorTables))
      .build();
  this.planner = Frameworks.getPlanner(config);

  for (String t : schema.getTableNames()) {
    sourceTables.put(t, (BaseBeamTable) schema.getTable(t));
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:32,代码来源:BeamQueryPlanner.java


示例18: checkComplexExpressionParsing

import org.apache.calcite.config.Lex; //导入依赖的package包/类
@Test
public void checkComplexExpressionParsing() throws Exception{
  FrameworkConfig config = Frameworks.newConfigBuilder() //
      .parserConfig(SqlParser.configBuilder()
          .setLex(Lex.MYSQL)
          .setIdentifierMaxLength(PlannerSettings.DEFAULT_IDENTIFIER_MAX_LENGTH)
          .setParserFactory(DrillParserImpl.FACTORY)
          .build()) //
      .defaultSchema(SimpleCalciteSchema.createRootSchema(false)) //
      .convertletTable(DrillConvertletTable.INSTANCE) //
      .build();
  Planner planner = Frameworks.getPlanner(config);

  SqlNode node = planner.parse(""
      + "select a[4].c \n"
      + "from x.y.z \n"
      + "where a.c.b = 5 and x[2] = 7 \n"
      + "group by d \n"
      + "having a.c < 5 \n"
      + "order by x.a.a.a.a.a");

  String expected = "SELECT `a`[4]['c']\n" +
      "FROM `x`.`y`.`z`\n" +
      "WHERE `a`.`c`['b'] = 5 AND `x`[2] = 7\n" +
      "GROUP BY `d`\n" +
      "HAVING `a`.`c` < 5\n" +
      "ORDER BY `x`.`a`['a']['a']['a']['a']";


  SqlNode rewritten = node.accept(new CompoundIdentifierConverter());
  String rewrittenQuery = rewritten.toString();

  DrillAssert.assertMultiLineStringEquals(expected, rewrittenQuery);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:35,代码来源:TestSqlBracketlessSyntax.java


示例19: buildFrameWorkConfig

import org.apache.calcite.config.Lex; //导入依赖的package包/类
/**
 * Method method build a calcite framework configuration for calcite to parse SQL and generate relational tree
 * out of it.
 * @return FrameworkConfig
 */
private FrameworkConfig buildFrameWorkConfig()
{
  List<SqlOperatorTable> sqlOperatorTables = new ArrayList<>();
  sqlOperatorTables.add(SqlStdOperatorTable.instance());
  sqlOperatorTables
    .add(new CalciteCatalogReader(CalciteSchema.from(schema), false, Collections.<String>emptyList(), typeFactory));
  return Frameworks.newConfigBuilder().defaultSchema(schema)
    .parserConfig(SqlParser.configBuilder().setLex(Lex.MYSQL).build())
    .operatorTable(new ChainedSqlOperatorTable(sqlOperatorTables)).build();
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:16,代码来源:SQLExecEnvironment.java


示例20: StreamlineParser

import org.apache.calcite.config.Lex; //导入依赖的package包/类
public StreamlineParser(String s) {
  this.impl = new StreamlineParserImpl(new StringReader(s));
  this.impl.setTabSize(1);
  this.impl.setQuotedCasing(Lex.ORACLE.quotedCasing);
  this.impl.setUnquotedCasing(Lex.ORACLE.unquotedCasing);
  this.impl.setIdentifierMaxLength(DEFAULT_IDENTIFIER_MAX_LENGTH);
  /*
   *  By default parser uses [ ] for quoting identifiers. Switching to DQID (double quoted identifiers)
   *  is needed for array and map access (m['x'] = 1 or arr[2] = 10 etc) to work.
   */
  this.impl.switchTo("DQID");
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:13,代码来源:StreamlineParser.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java CompletedExecutionInstruction类代码示例发布时间:2022-05-22
下一篇:
Java Caller类代码示例发布时间: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