本文整理汇总了Java中org.apache.calcite.sql.SqlOperatorTable类的典型用法代码示例。如果您正苦于以下问题:Java SqlOperatorTable类的具体用法?Java SqlOperatorTable怎么用?Java SqlOperatorTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlOperatorTable类属于org.apache.calcite.sql包,在下文中一共展示了SqlOperatorTable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:CalciteCatalogReader.java
示例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);
}
开发者ID:apache,项目名称:calcite,代码行数:30,代码来源:SqlValidatorImpl.java
示例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);
}
}
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:CalciteConnectionConfigImpl.java
示例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;
}
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:Frameworks.java
示例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));
}
}
开发者ID:apache,项目名称:beam,代码行数:32,代码来源:BeamQueryPlanner.java
示例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();
}
开发者ID:apache,项目名称:apex-malhar,代码行数:16,代码来源:SQLExecEnvironment.java
示例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();
}
}
开发者ID:hortonworks,项目名称:streamline,代码行数:14,代码来源:StreamlineSqlImpl.java
示例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);
}
开发者ID:hortonworks,项目名称:streamline,代码行数:31,代码来源:TestCompilerUtils.java
示例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);
}
开发者ID:apache,项目名称:kylin,代码行数:13,代码来源:CalcitePrepareImpl.java
示例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);
}
开发者ID:apache,项目名称:calcite,代码行数:13,代码来源:CalcitePrepareImpl.java
示例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);
}
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:SqlValidatorUtil.java
示例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);
}
}
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:ChainedSqlOperatorTable.java
示例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;
}
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:ChainedSqlOperatorTable.java
示例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);
}
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:DefaultSqlTestFactory.java
示例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;
}
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:DefaultSqlTestFactory.java
示例16: testValidateUserDefinedAggregate
import org.apache.calcite.sql.SqlOperatorTable; //导入依赖的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"));
}
}
开发者ID:apache,项目名称:calcite,代码行数:40,代码来源:PlannerTest.java
示例17: createOperatorTable
import org.apache.calcite.sql.SqlOperatorTable; //导入依赖的package包/类
/**
* Creates an operator table.
*
* @return New operator table
*/
protected SqlOperatorTable createOperatorTable() {
final MockSqlOperatorTable opTab =
new MockSqlOperatorTable(SqlStdOperatorTable.instance());
MockSqlOperatorTable.addRamp(opTab);
return opTab;
}
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:SqlToRelTestBase.java
示例18: FarragoTestValidator
import org.apache.calcite.sql.SqlOperatorTable; //导入依赖的package包/类
FarragoTestValidator(
SqlOperatorTable opTab,
SqlValidatorCatalogReader catalogReader,
RelDataTypeFactory typeFactory,
SqlConformance conformance) {
super(opTab, catalogReader, typeFactory, conformance);
}
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:SqlToRelTestBase.java
示例19: FeatureValidator
import org.apache.calcite.sql.SqlOperatorTable; //导入依赖的package包/类
protected FeatureValidator(
SqlOperatorTable opTab,
SqlValidatorCatalogReader catalogReader,
RelDataTypeFactory typeFactory,
SqlConformance conformance) {
super(opTab, catalogReader, typeFactory, conformance);
}
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:SqlValidatorFeatureTest.java
示例20: SqlValidatorImpl
import org.apache.calcite.sql.SqlOperatorTable; //导入依赖的package包/类
protected SqlValidatorImpl(FlattenOpCounter flattenCount, SqlOperatorTable opTab, SqlValidatorCatalogReader catalogReader,
RelDataTypeFactory typeFactory, SqlConformance conformance) {
super(opTab, catalogReader, typeFactory, conformance);
this.flattenCount = flattenCount;
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:6,代码来源:SqlValidatorImpl.java
注:本文中的org.apache.calcite.sql.SqlOperatorTable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论