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


Java SqlAdvisor类代码示例

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


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

示例1: assertHint

import org.apache.calcite.sql.advise.SqlAdvisor; //导入依赖的package包/类
/**
 * Checks that a given SQL statement yields the expected set of completion
 * hints.
 *
 * @param sql             SQL statement
 * @param expectedResults Expected list of hints
 * @throws Exception on error
 */
protected void assertHint(
    String sql,
    String expectedResults) throws Exception {
  SqlValidatorWithHints validator =
      (SqlValidatorWithHints) tester.getValidator();
  SqlAdvisor advisor = tester.getFactory().createAdvisor(validator);

  SqlParserUtil.StringAndPos sap = SqlParserUtil.findPos(sql);

  List<SqlMoniker> results =
      advisor.getCompletionHints(
          sap.sql,
          sap.pos);
  Assert.assertEquals(
      expectedResults, convertCompletionHints(results));
}
 
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:SqlAdvisorTest.java

示例2: assertComplete

import org.apache.calcite.sql.advise.SqlAdvisor; //导入依赖的package包/类
/**
 * Tests that a given SQL which may be invalid or incomplete simplifies
 * itself and yields the salesTables set of completion hints. This is an
 * integration test of {@link #assertHint} and {@link #assertSimplify}.
 *
 * @param sql             SQL statement
 * @param expectedResults Expected list of hints
 * @param expectedWord    Word that we expect to be replaced, or null if we
 *                        don't care
 */
protected void assertComplete(
    String sql,
    String expectedResults,
    String expectedWord) {
  SqlValidatorWithHints validator =
      (SqlValidatorWithHints) tester.getValidator();
  SqlAdvisor advisor = tester.getFactory().createAdvisor(validator);

  SqlParserUtil.StringAndPos sap = SqlParserUtil.findPos(sql);
  final String[] replaced = {null};
  List<SqlMoniker> results =
      advisor.getCompletionHints(sap.sql, sap.cursor, replaced);
  assertNotNull(replaced[0]);
  assertNotNull(results);
  Assert.assertEquals(
      expectedResults, convertCompletionHints(results));
  if (expectedWord != null) {
    Assert.assertEquals(expectedWord, replaced[0]);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:31,代码来源:SqlAdvisorTest.java

示例3: getSqlAdvisor

import org.apache.calcite.sql.advise.SqlAdvisor; //导入依赖的package包/类
private SqlAdvisor getSqlAdvisor() {
    final CalciteConnectionImpl con = (CalciteConnectionImpl) queryProvider;
    final String schemaName = con.getSchema();
    final List<String> schemaPath =
            schemaName == null
                    ? ImmutableList.<String>of()
                    : ImmutableList.of(schemaName);
    final SqlValidatorWithHints validator =
            new SqlAdvisorValidator(SqlStdOperatorTable.instance(),
                    new CalciteCatalogReader(rootSchema, con.config().caseSensitive(),
                            schemaPath, typeFactory),
                    typeFactory, SqlConformance.DEFAULT);
    return new SqlAdvisor(validator);
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:15,代码来源:CalciteConnectionImpl.java

示例4: getSqlAdvisor

import org.apache.calcite.sql.advise.SqlAdvisor; //导入依赖的package包/类
private SqlAdvisor getSqlAdvisor() {
  final CalciteConnectionImpl con = (CalciteConnectionImpl) queryProvider;
  final String schemaName = con.getSchema();
  final List<String> schemaPath =
      schemaName == null
          ? ImmutableList.<String>of()
          : ImmutableList.of(schemaName);
  final SqlValidatorWithHints validator =
      new SqlAdvisorValidator(SqlStdOperatorTable.instance(),
      new CalciteCatalogReader(rootSchema,
          schemaPath, typeFactory, con.config()),
      typeFactory, SqlConformanceEnum.DEFAULT);
  return new SqlAdvisor(validator);
}
 
开发者ID:apache,项目名称:calcite,代码行数:15,代码来源:CalciteConnectionImpl.java

示例5: assertSimplify

import org.apache.calcite.sql.advise.SqlAdvisor; //导入依赖的package包/类
/**
 * Tests that a given SQL statement simplifies to the salesTables result.
 *
 * @param sql      SQL statement to simplify. The SQL statement must contain
 *                 precisely one caret '^', which marks the location where
 *                 completion is to occur.
 * @param expected Expected result after simplification.
 */
protected void assertSimplify(String sql, String expected) {
  SqlValidatorWithHints validator =
      (SqlValidatorWithHints) tester.getValidator();
  SqlAdvisor advisor = tester.getFactory().createAdvisor(validator);

  SqlParserUtil.StringAndPos sap = SqlParserUtil.findPos(sql);
  String actual = advisor.simplifySql(sap.sql, sap.cursor);
  Assert.assertEquals(expected, actual);
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:SqlAdvisorTest.java

示例6: createAdvisor

import org.apache.calcite.sql.advise.SqlAdvisor; //导入依赖的package包/类
@Override public SqlAdvisor createAdvisor(SqlValidatorWithHints validator) {
  return new SqlAdvisor(validator);
}
 
开发者ID:apache,项目名称:calcite,代码行数:4,代码来源:SqlAdvisorTest.java

示例7: createAdvisor

import org.apache.calcite.sql.advise.SqlAdvisor; //导入依赖的package包/类
public SqlAdvisor createAdvisor(SqlValidatorWithHints validator) {
  return factory.createAdvisor(validator);
}
 
开发者ID:apache,项目名称:calcite,代码行数:4,代码来源:DelegatingSqlTestFactory.java

示例8: createAdvisor

import org.apache.calcite.sql.advise.SqlAdvisor; //导入依赖的package包/类
public SqlAdvisor createAdvisor(SqlValidatorWithHints validator) {
  throw new UnsupportedOperationException();
}
 
开发者ID:apache,项目名称:calcite,代码行数:4,代码来源:DefaultSqlTestFactory.java

示例9: createAdvisor

import org.apache.calcite.sql.advise.SqlAdvisor; //导入依赖的package包/类
SqlAdvisor createAdvisor(SqlValidatorWithHints validator); 
开发者ID:apache,项目名称:calcite,代码行数:2,代码来源:SqlTestFactory.java


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