本文整理汇总了Java中org.apache.calcite.sql.fun.SqlStdOperatorTable.instance方法的典型用法代码示例。如果您正苦于以下问题:Java SqlStdOperatorTable.instance方法的具体用法?Java SqlStdOperatorTable.instance怎么用?Java SqlStdOperatorTable.instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.sql.fun.SqlStdOperatorTable
的用法示例。
在下文中一共展示了SqlStdOperatorTable.instance方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SqlToRelConverter
import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入方法依赖的package包/类
public SqlToRelConverter(
RelOptTable.ViewExpander viewExpander,
SqlValidator validator,
Prepare.CatalogReader catalogReader,
RelOptCluster cluster,
SqlRexConvertletTable convertletTable,
Config config) {
this.viewExpander = viewExpander;
this.opTab =
(validator
== null) ? SqlStdOperatorTable.instance()
: validator.getOperatorTable();
this.validator = validator;
this.catalogReader = catalogReader;
this.subQueryConverter = new NoOpSubQueryConverter();
this.rexBuilder = cluster.getRexBuilder();
this.typeFactory = rexBuilder.getTypeFactory();
this.cluster = Preconditions.checkNotNull(cluster);
this.exprConverter = new SqlNodeToRexConverterImpl(convertletTable);
this.explainParamCount = 0;
this.config = new ConfigBuilder().withConfig(config).build();
}
示例2: SqlToRelConverter
import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入方法依赖的package包/类
public SqlToRelConverter(
RelOptTable.ViewExpander viewExpander,
SqlValidator validator,
Prepare.CatalogReader catalogReader,
RelOptCluster cluster,
SqlRexConvertletTable convertletTable,
Config config) {
this.viewExpander = viewExpander;
this.opTab =
(validator
== null) ? SqlStdOperatorTable.instance()
: validator.getOperatorTable();
this.validator = validator;
this.catalogReader = catalogReader;
this.subQueryConverter = new NoOpSubQueryConverter();
this.rexBuilder = cluster.getRexBuilder();
this.typeFactory = rexBuilder.getTypeFactory();
this.cluster = Preconditions.checkNotNull(cluster);
this.exprConverter = new SqlNodeToRexConverterImpl(convertletTable);
this.explainParamCount = 0;
this.config = new ConfigBuilder().withConfig(config).build();
}
示例3: SqlToRelConverter
import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入方法依赖的package包/类
public SqlToRelConverter(
RelOptTable.ViewExpander viewExpander,
SqlValidator validator,
Prepare.CatalogReader catalogReader,
RelOptCluster cluster,
SqlRexConvertletTable convertletTable,
Config config) {
this.viewExpander = viewExpander;
this.opTab =
(validator
== null) ? SqlStdOperatorTable.instance()
: validator.getOperatorTable();
this.validator = validator;
this.catalogReader = catalogReader;
this.subQueryConverter = new NoOpSubQueryConverter();
this.rexBuilder = cluster.getRexBuilder();
this.typeFactory = rexBuilder.getTypeFactory();
this.cluster = Preconditions.checkNotNull(cluster);
this.exprConverter = new SqlNodeToRexConverterImpl(convertletTable);
this.explainParamCount = 0;
this.config = new ConfigBuilder().withConfig(config).build();
this.relBuilder = config.getRelBuilderFactory().create(cluster, null);
}
示例4: testSqlOperatorOverloading
import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入方法依赖的package包/类
@Test public void testSqlOperatorOverloading() {
final SqlStdOperatorTable operatorTable = SqlStdOperatorTable.instance();
for (SqlOperator sqlOperator : operatorTable.getOperatorList()) {
String operatorName = sqlOperator.getName();
List<SqlOperator> routines = new ArrayList<>();
operatorTable.lookupOperatorOverloads(
new SqlIdentifier(operatorName, SqlParserPos.ZERO),
null,
sqlOperator.getSyntax(),
routines);
Iterator<SqlOperator> iter = routines.iterator();
while (iter.hasNext()) {
SqlOperator operator = iter.next();
if (!sqlOperator.getClass().isInstance(operator)) {
iter.remove();
}
}
assertThat(routines.size(), equalTo(1));
assertThat(sqlOperator, equalTo(routines.get(0)));
}
}
示例5: getSqlAdvisor
import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入方法依赖的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);
}
示例6: getSqlAdvisor
import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入方法依赖的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);
}
示例7: getValidator
import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入方法依赖的package包/类
@Override public SqlValidator getValidator(SqlTestFactory factory) {
final RelDataTypeFactory typeFactory =
new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
final SqlConformance conformance = (SqlConformance) get("conformance");
final boolean caseSensitive = (Boolean) factory.get("caseSensitive");
return new SqlAdvisorValidator(
SqlStdOperatorTable.instance(),
new MockCatalogReader(typeFactory, caseSensitive).init(),
typeFactory,
conformance);
}
示例8: testValidateUserDefinedAggregate
import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入方法依赖的package包/类
@Test public void testValidateUserDefinedAggregate() throws Exception {
final SqlStdOperatorTable stdOpTab = SqlStdOperatorTable.instance();
SqlOperatorTable opTab =
ChainedSqlOperatorTable.of(stdOpTab,
new ListSqlOperatorTable(
ImmutableList.<SqlOperator>of(new MyCountAggFunction())));
final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
final FrameworkConfig config = Frameworks.newConfigBuilder()
.defaultSchema(
CalciteAssert.addSchema(rootSchema, CalciteAssert.SchemaSpec.HR))
.operatorTable(opTab)
.build();
final Planner planner = Frameworks.getPlanner(config);
SqlNode parse =
planner.parse("select \"deptno\", my_count(\"empid\") from \"emps\"\n"
+ "group by \"deptno\"");
assertThat(Util.toLinux(parse.toString()),
equalTo("SELECT `deptno`, `MY_COUNT`(`empid`)\n"
+ "FROM `emps`\n"
+ "GROUP BY `deptno`"));
// MY_COUNT is recognized as an aggregate function, and therefore it is OK
// that its argument empid is not in the GROUP BY clause.
SqlNode validate = planner.validate(parse);
assertThat(validate, notNullValue());
// The presence of an aggregate function in the SELECT clause causes it
// to become an aggregate query. Non-aggregate expressions become illegal.
planner.close();
planner.reset();
parse = planner.parse("select \"deptno\", count(1) from \"emps\"");
try {
validate = planner.validate(parse);
fail("expected exception, got " + validate);
} catch (ValidationException e) {
assertThat(e.getCause().getCause().getMessage(),
containsString("Expression 'deptno' is not being grouped"));
}
}
示例9: createOperatorTable
import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入方法依赖的package包/类
/**
* Creates an operator table.
*
* @return New operator table
*/
protected SqlOperatorTable createOperatorTable() {
final MockSqlOperatorTable opTab =
new MockSqlOperatorTable(SqlStdOperatorTable.instance());
MockSqlOperatorTable.addRamp(opTab);
return opTab;
}