本文整理汇总了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));
}
示例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]);
}
}
示例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);
}
示例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);
}
示例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);
}
示例6: createAdvisor
import org.apache.calcite.sql.advise.SqlAdvisor; //导入依赖的package包/类
@Override public SqlAdvisor createAdvisor(SqlValidatorWithHints validator) {
return new SqlAdvisor(validator);
}
示例7: createAdvisor
import org.apache.calcite.sql.advise.SqlAdvisor; //导入依赖的package包/类
public SqlAdvisor createAdvisor(SqlValidatorWithHints validator) {
return factory.createAdvisor(validator);
}
示例8: createAdvisor
import org.apache.calcite.sql.advise.SqlAdvisor; //导入依赖的package包/类
public SqlAdvisor createAdvisor(SqlValidatorWithHints validator) {
throw new UnsupportedOperationException();
}
示例9: createAdvisor
import org.apache.calcite.sql.advise.SqlAdvisor; //导入依赖的package包/类
SqlAdvisor createAdvisor(SqlValidatorWithHints validator);