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


Java SqlParser.parseQuery方法代码示例

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


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

示例1: stripNamespace

import org.apache.calcite.sql.parser.SqlParser; //导入方法依赖的package包/类
/**
 * Strips the dataSource name from the query
 * @param query
 * @param dataSource
 * @return
 * @throws QuarkException
 */
private String stripNamespace(final String query,
                              final DataSourceSchema dataSource)
    throws QuarkException {
  String result = query.replace("\n", " ");
  if (dataSource != null) {
    try {
      final SqlParser parser = getSqlParser(query);
      SqlNode node = parser.parseQuery();
      result = stripNamespace(node, dataSource.getName(),
          dataSource.getDataSource().getSqlDialect());
    } catch (Exception e) {
      LOG.warn("Exception while parsing the input query: " + e.getMessage());
    }
  }
  return result;
}
 
开发者ID:qubole,项目名称:quark,代码行数:24,代码来源:SqlQueryParser.java

示例2: expandView

import org.apache.calcite.sql.parser.SqlParser; //导入方法依赖的package包/类
@Override public RelRoot expandView(RelDataType rowType, String queryString,
                                    List<String> schemaPath, List<String> viewPath) {
  expansionDepth++;

  SqlParser parser = prepare.createParser(queryString);
  SqlNode sqlNode;
  try {
    sqlNode = parser.parseQuery();
  } catch (SqlParseException e) {
    throw new RuntimeException("parse failed", e);
  }
  // View may have different schema path than current connection.
  final CatalogReader catalogReader =
      this.catalogReader.withSchemaPath(schemaPath);
  SqlValidator validator = createSqlValidator(catalogReader);
  SqlNode sqlNode1 = validator.validate(sqlNode);
  final SqlToRelConverter.Config config = SqlToRelConverter.configBuilder()
          .withTrimUnusedFields(true).build();
  SqlToRelConverter sqlToRelConverter =
      getSqlToRelConverter(validator, catalogReader, config);
  RelRoot root =
      sqlToRelConverter.convertQuery(sqlNode1, true, false);

  --expansionDepth;
  return root;
}
 
开发者ID:apache,项目名称:kylin,代码行数:27,代码来源:CalcitePrepareImpl.java

示例3: expandView

import org.apache.calcite.sql.parser.SqlParser; //导入方法依赖的package包/类
@Override public RelRoot expandView(RelDataType rowType, String queryString,
    List<String> schemaPath, List<String> viewPath) {
  expansionDepth++;

  SqlParser parser = prepare.createParser(queryString);
  SqlNode sqlNode;
  try {
    sqlNode = parser.parseQuery();
  } catch (SqlParseException e) {
    throw new RuntimeException("parse failed", e);
  }
  // View may have different schema path than current connection.
  final CatalogReader catalogReader =
      this.catalogReader.withSchemaPath(schemaPath);
  SqlValidator validator = createSqlValidator(catalogReader);
  SqlNode sqlNode1 = validator.validate(sqlNode);
  final SqlToRelConverter.Config config = SqlToRelConverter.configBuilder()
          .withTrimUnusedFields(true).build();
  SqlToRelConverter sqlToRelConverter =
      getSqlToRelConverter(validator, catalogReader, config);
  RelRoot root =
      sqlToRelConverter.convertQuery(sqlNode1, true, false);

  --expansionDepth;
  return root;
}
 
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:CalcitePrepareImpl.java

示例4: checkSqlParsing

import org.apache.calcite.sql.parser.SqlParser; //导入方法依赖的package包/类
public static void checkSqlParsing(String sql, Properties info, String expectedSql,
    SqlDialect dialect)
    throws QuarkException, SqlParseException {
  SqlQueryParser parser = new SqlQueryParser(info);
  SqlParser sqlParser = parser.getSqlParser(sql);
  SqlNode sqlNode = sqlParser.parseQuery();
  String finalQuery = sqlNode.toSqlString(dialect).getSql();
  assertEquals(expectedSql, finalQuery.replace("\n", " "));
}
 
开发者ID:qubole,项目名称:quark,代码行数:10,代码来源:QuarkTestUtil.java

示例5: expandView

import org.apache.calcite.sql.parser.SqlParser; //导入方法依赖的package包/类
@Override public RelRoot expandView(RelDataType rowType, String queryString,
  List<String> schemaPath, List<String> viewPath) {
  SqlParser parser = SqlParser.create(queryString, parserConfig);
  SqlNode sqlNode;
  try {
    sqlNode = parser.parseQuery();
  } catch (SqlParseException e) {
    throw new RuntimeException("parse failed", e);
  }

  final SqlConformance conformance = conformance();
  final CalciteCatalogReader catalogReader =
      createCatalogReader().withSchemaPath(schemaPath);
  final SqlValidator validator =
      new CalciteSqlValidator(operatorTable, catalogReader, typeFactory,
          conformance);
  validator.setIdentifierExpansion(true);
  final SqlNode validatedSqlNode = validator.validate(sqlNode);

  final RexBuilder rexBuilder = createRexBuilder();
  final RelOptCluster cluster = RelOptCluster.create(planner, rexBuilder);
  final SqlToRelConverter.Config config = SqlToRelConverter
      .configBuilder()
      .withConfig(sqlToRelConverterConfig)
      .withTrimUnusedFields(false)
      .withConvertTableAccess(false)
      .build();
  final SqlToRelConverter sqlToRelConverter =
      new SqlToRelConverter(new ViewExpanderImpl(), validator,
          catalogReader, cluster, convertletTable, config);

  root = sqlToRelConverter.convertQuery(validatedSqlNode, true, false);
  root = root.withRel(sqlToRelConverter.flattenTypes(root.rel, true));
  root = root.withRel(RelDecorrelator.decorrelateQuery(root.rel));

  return PlannerImpl.this.root;
}
 
开发者ID:apache,项目名称:calcite,代码行数:38,代码来源:PlannerImpl.java

示例6: parse

import org.apache.calcite.sql.parser.SqlParser; //导入方法依赖的package包/类
public static SqlNode parse(String sql) throws SqlParseException {
    SqlParser.ConfigBuilder parserBuilder = SqlParser.configBuilder();
    SqlParser sqlParser = SqlParser.create(sql, parserBuilder.build());
    return sqlParser.parseQuery();
}
 
开发者ID:apache,项目名称:kylin,代码行数:6,代码来源:CalciteParser.java

示例7: parseQuery

import org.apache.calcite.sql.parser.SqlParser; //导入方法依赖的package包/类
public SqlNode parseQuery(String sql) throws SqlParseException {
  SqlParser parser = factory.createParser(factory, sql);
  return parser.parseQuery();
}
 
开发者ID:apache,项目名称:calcite,代码行数:5,代码来源:SqlTesterImpl.java

示例8: parseQuery

import org.apache.calcite.sql.parser.SqlParser; //导入方法依赖的package包/类
public SqlNode parseQuery(String sql) throws Exception {
  SqlParser parser = SqlParser.create(sql);
  return parser.parseQuery();
}
 
开发者ID:apache,项目名称:calcite,代码行数:5,代码来源:SqlToRelTestBase.java


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