本文整理汇总了Java中org.apache.calcite.sql.SqlOperatorTable类的典型用法代码示例。如果您正苦于以下问题:Java SqlOperatorTable类的具体用法?Java SqlOperatorTable怎么用?Java SqlOperatorTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlOperatorTable类属于org.apache.calcite.sql包,在下文中一共展示了SqlOperatorTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: operatorTable
import org.apache.calcite.sql.SqlOperatorTable; //导入依赖的package包/类
/** Creates an operator table that contains functions in the given class.
*
* @see ModelHandler#addFunctions */
public static SqlOperatorTable operatorTable(String className) {
// Dummy schema to collect the functions
final CalciteSchema schema =
CalciteSchema.createRootSchema(false, false);
ModelHandler.addFunctions(schema.plus(), null, ImmutableList.<String>of(),
className, "*", true);
// The following is technical debt; see [CALCITE-2082] Remove
// RelDataTypeFactory argument from SqlUserDefinedAggFunction constructor
final SqlTypeFactoryImpl typeFactory =
new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
final ListSqlOperatorTable table = new ListSqlOperatorTable();
for (String name : schema.getFunctionNames()) {
for (Function function : schema.getFunctions(name, true)) {
final SqlIdentifier id = new SqlIdentifier(name, SqlParserPos.ZERO);
table.add(
toOp(typeFactory, id, function));
}
}
return table;
}
示例2: SqlValidatorImpl
import org.apache.calcite.sql.SqlOperatorTable; //导入依赖的package包/类
/**
* Creates a validator.
*
* @param opTab Operator table
* @param catalogReader Catalog reader
* @param typeFactory Type factory
* @param conformance Compatibility mode
*/
protected SqlValidatorImpl(
SqlOperatorTable opTab,
SqlValidatorCatalogReader catalogReader,
RelDataTypeFactory typeFactory,
SqlConformance conformance) {
this.opTab = Preconditions.checkNotNull(opTab);
this.catalogReader = Preconditions.checkNotNull(catalogReader);
this.typeFactory = Preconditions.checkNotNull(typeFactory);
this.conformance = Preconditions.checkNotNull(conformance);
unknownType = typeFactory.createUnknownType();
booleanType = typeFactory.createSqlType(SqlTypeName.BOOLEAN);
rewriteCalls = true;
expandColumnReferences = true;
aggFinder = new AggFinder(opTab, false, true, false, null);
aggOrOverFinder = new AggFinder(opTab, true, true, false, null);
overFinder = new AggFinder(opTab, true, false, false, aggOrOverFinder);
groupFinder = new AggFinder(opTab, false, false, true, null);
aggOrOverOrGroupFinder = new AggFinder(opTab, true, true, true, null);
}
示例3: operatorTable
import org.apache.calcite.sql.SqlOperatorTable; //导入依赖的package包/类
private static void operatorTable(String s,
Collection<SqlOperatorTable> tables) {
switch (s) {
case "standard":
tables.add(SqlStdOperatorTable.instance());
return;
case "oracle":
tables.add(OracleSqlOperatorTable.instance());
return;
case "spatial":
tables.add(
CalciteCatalogReader.operatorTable(GeoFunctions.class.getName()));
return;
default:
throw new IllegalArgumentException("Unknown operator table: " + s);
}
}
示例4: StdFrameworkConfig
import org.apache.calcite.sql.SqlOperatorTable; //导入依赖的package包/类
StdFrameworkConfig(Context context,
SqlRexConvertletTable convertletTable,
SqlOperatorTable operatorTable,
ImmutableList<Program> programs,
ImmutableList<RelTraitDef> traitDefs,
SqlParser.Config parserConfig,
SqlToRelConverter.Config sqlToRelConverterConfig,
SchemaPlus defaultSchema,
RelOptCostFactory costFactory,
RelDataTypeSystem typeSystem,
RexExecutor executor) {
this.context = context;
this.convertletTable = convertletTable;
this.operatorTable = operatorTable;
this.programs = programs;
this.traitDefs = traitDefs;
this.parserConfig = parserConfig;
this.sqlToRelConverterConfig = sqlToRelConverterConfig;
this.defaultSchema = defaultSchema;
this.costFactory = costFactory;
this.typeSystem = typeSystem;
this.executor = executor;
}
示例5: BeamQueryPlanner
import org.apache.calcite.sql.SqlOperatorTable; //导入依赖的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));
}
}
示例6: buildFrameWorkConfig
import org.apache.calcite.sql.SqlOperatorTable; //导入依赖的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();
}
示例7: buildFrameWorkConfig
import org.apache.calcite.sql.SqlOperatorTable; //导入依赖的package包/类
private FrameworkConfig buildFrameWorkConfig() {
if (hasUdf) {
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)
.operatorTable(new ChainedSqlOperatorTable(sqlOperatorTables)).build();
} else {
return Frameworks.newConfigBuilder().defaultSchema(schema).build();
}
}
示例8: sqlOverDummyTable
import org.apache.calcite.sql.SqlOperatorTable; //导入依赖的package包/类
public static CalciteState sqlOverDummyTable(String sql)
throws RelConversionException, ValidationException, SqlParseException {
SchemaPlus schema = Frameworks.createRootSchema(true);
JavaTypeFactory typeFactory = new JavaTypeFactoryImpl
(RelDataTypeSystem.DEFAULT);
StreamableTable streamableTable = new CompilerUtil.TableBuilderInfo(typeFactory)
.field("ID", SqlTypeName.INTEGER)
.field("NAME", typeFactory.createType(String.class))
.field("ADDR", typeFactory.createType(String.class))
.build();
Table table = streamableTable.stream();
schema.add("FOO", table);
schema.add("BAR", table);
schema.add("MYPLUS", ScalarFunctionImpl.create(MyPlus.class, "eval"));
List<SqlOperatorTable> sqlOperatorTables = new ArrayList<>();
sqlOperatorTables.add(SqlStdOperatorTable.instance());
sqlOperatorTables.add(new CalciteCatalogReader(CalciteSchema.from(schema),
false,
Collections.<String>emptyList(), typeFactory));
SqlOperatorTable chainedSqlOperatorTable = new ChainedSqlOperatorTable(sqlOperatorTables);
FrameworkConfig config = Frameworks.newConfigBuilder().defaultSchema(
schema).operatorTable(chainedSqlOperatorTable).build();
Planner planner = Frameworks.getPlanner(config);
SqlNode parse = planner.parse(sql);
SqlNode validate = planner.validate(parse);
RelNode tree = planner.convert(validate);
System.out.println(RelOptUtil.toString(tree, SqlExplainLevel.ALL_ATTRIBUTES));
return new CalciteState(schema, tree);
}
示例9: createSqlValidator
import org.apache.calcite.sql.SqlOperatorTable; //导入依赖的package包/类
private SqlValidator createSqlValidator(Context context,
CalciteCatalogReader catalogReader) {
final SqlOperatorTable opTab0 =
context.config().fun(SqlOperatorTable.class,
SqlStdOperatorTable.instance());
final SqlOperatorTable opTab =
ChainedSqlOperatorTable.of(opTab0, catalogReader);
final JavaTypeFactory typeFactory = context.getTypeFactory();
final SqlConformance conformance = context.config().conformance();
return new CalciteSqlValidator(opTab, catalogReader, typeFactory,
conformance);
}
示例10: createSqlValidator
import org.apache.calcite.sql.SqlOperatorTable; //导入依赖的package包/类
private SqlValidator createSqlValidator(Context context,
CalciteCatalogReader catalogReader) {
final SqlOperatorTable opTab0 =
context.config().fun(SqlOperatorTable.class,
SqlStdOperatorTable.instance());
final SqlOperatorTable opTab =
ChainedSqlOperatorTable.of(opTab0, catalogReader);
final JavaTypeFactory typeFactory = context.getTypeFactory();
final SqlConformance conformance = context.config().conformance();
return new CalciteSqlValidator(opTab, catalogReader, typeFactory,
conformance);
}
示例11: newValidator
import org.apache.calcite.sql.SqlOperatorTable; //导入依赖的package包/类
/**
* Factory method for {@link SqlValidator}.
*/
public static SqlValidatorWithHints newValidator(
SqlOperatorTable opTab,
SqlValidatorCatalogReader catalogReader,
RelDataTypeFactory typeFactory,
SqlConformance conformance) {
return new SqlValidatorImpl(opTab, catalogReader, typeFactory,
conformance);
}
示例12: lookupOperatorOverloads
import org.apache.calcite.sql.SqlOperatorTable; //导入依赖的package包/类
public void lookupOperatorOverloads(SqlIdentifier opName,
SqlFunctionCategory category, SqlSyntax syntax,
List<SqlOperator> operatorList) {
for (SqlOperatorTable table : tableList) {
table.lookupOperatorOverloads(opName, category, syntax, operatorList);
}
}
示例13: getOperatorList
import org.apache.calcite.sql.SqlOperatorTable; //导入依赖的package包/类
public List<SqlOperator> getOperatorList() {
List<SqlOperator> list = new ArrayList<>();
for (SqlOperatorTable table : tableList) {
list.addAll(table.getOperatorList());
}
return list;
}
示例14: load
import org.apache.calcite.sql.SqlOperatorTable; //导入依赖的package包/类
public Xyz load(@Nonnull SqlTestFactory factory)
throws Exception {
final SqlOperatorTable operatorTable =
factory.createOperatorTable(factory);
final JavaTypeFactory typeFactory =
new JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
final MockCatalogReader catalogReader =
factory.createCatalogReader(factory, typeFactory);
return new Xyz(operatorTable, typeFactory, catalogReader);
}
示例15: createOperatorTable
import org.apache.calcite.sql.SqlOperatorTable; //导入依赖的package包/类
public SqlOperatorTable createOperatorTable(SqlTestFactory factory) {
final SqlOperatorTable opTab0 =
(SqlOperatorTable) factory.get("operatorTable");
MockSqlOperatorTable opTab = new MockSqlOperatorTable(opTab0);
MockSqlOperatorTable.addRamp(opTab);
return opTab;
}