本文整理汇总了Java中org.apache.calcite.prepare.Prepare类的典型用法代码示例。如果您正苦于以下问题:Java Prepare类的具体用法?Java Prepare怎么用?Java Prepare使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Prepare类属于org.apache.calcite.prepare包,在下文中一共展示了Prepare类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SqlToRelConverter
import org.apache.calcite.prepare.Prepare; //导入依赖的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: JdbcTableModify
import org.apache.calcite.prepare.Prepare; //导入依赖的package包/类
public JdbcTableModify(RelOptCluster cluster,
RelTraitSet traitSet,
RelOptTable table,
Prepare.CatalogReader catalogReader,
RelNode input,
Operation operation,
List<String> updateColumnList,
boolean flattened) {
super(cluster, traitSet, table, catalogReader, input, operation,
updateColumnList, flattened);
assert input.getConvention() instanceof JdbcConvention;
assert getConvention() instanceof JdbcConvention;
final ModifiableTable modifiableTable =
table.unwrap(ModifiableTable.class);
if (modifiableTable == null) {
throw new AssertionError(); // TODO: user error in validator
}
this.expression = table.getExpression(Queryable.class);
if (expression == null) {
throw new AssertionError(); // TODO: user error in validator
}
}
示例3: SqlToRelConverter
import org.apache.calcite.prepare.Prepare; //导入依赖的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();
}
示例4: JdbcTableModify
import org.apache.calcite.prepare.Prepare; //导入依赖的package包/类
public JdbcTableModify(RelOptCluster cluster,
RelTraitSet traitSet,
RelOptTable table,
Prepare.CatalogReader catalogReader,
RelNode input,
Operation operation,
List<String> updateColumnList,
List<RexNode> sourceExpressionList,
boolean flattened) {
super(cluster, traitSet, table, catalogReader, input, operation,
updateColumnList, sourceExpressionList, flattened);
assert input.getConvention() instanceof JdbcConvention;
assert getConvention() instanceof JdbcConvention;
final ModifiableTable modifiableTable =
table.unwrap(ModifiableTable.class);
if (modifiableTable == null) {
throw new AssertionError(); // TODO: user error in validator
}
this.expression = table.getExpression(Queryable.class);
if (expression == null) {
throw new AssertionError(); // TODO: user error in validator
}
}
示例5: SqlToRelConverter
import org.apache.calcite.prepare.Prepare; //导入依赖的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);
}
示例6: validateUpdate
import org.apache.calcite.prepare.Prepare; //导入依赖的package包/类
public void validateUpdate(SqlUpdate call) {
final SqlValidatorNamespace targetNamespace = getNamespace(call);
validateNamespace(targetNamespace, unknownType);
final RelOptTable relOptTable = SqlValidatorUtil.getRelOptTable(
targetNamespace, catalogReader.unwrap(Prepare.CatalogReader.class), null, null);
final SqlValidatorTable table = relOptTable == null
? targetNamespace.getTable()
: relOptTable.unwrap(SqlValidatorTable.class);
final RelDataType targetRowType =
createTargetRowType(
table,
call.getTargetColumnList(),
true);
final SqlSelect select = call.getSourceSelect();
validateSelect(select, targetRowType);
final RelDataType sourceRowType = getNamespace(call).getRowType();
checkTypeAssignment(sourceRowType, targetRowType, call);
checkConstraint(table, call, targetRowType);
validateAccess(call.getTargetTable(), table, SqlAccessEnum.UPDATE);
}
示例7: getRelOptTable
import org.apache.calcite.prepare.Prepare; //导入依赖的package包/类
private static RelOptTable getRelOptTable(
TableNamespace tableNamespace,
Prepare.CatalogReader catalogReader,
String datasetName,
boolean[] usedDataset,
List<RelDataTypeField> extendedFields) {
final List<String> names = tableNamespace.getTable().getQualifiedName();
RelOptTable table;
if (datasetName != null
&& catalogReader instanceof RelOptSchemaWithSampling) {
final RelOptSchemaWithSampling reader =
(RelOptSchemaWithSampling) catalogReader;
table = reader.getTableForMember(names, datasetName, usedDataset);
} else {
// Schema does not support substitution. Ignore the data set, if any.
table = catalogReader.getTableForMember(names);
}
if (!extendedFields.isEmpty()) {
table = table.extend(extendedFields);
}
return table;
}
示例8: checkThatMaterialize
import org.apache.calcite.prepare.Prepare; //导入依赖的package包/类
/** Checks that a given query can use a materialized view with a given
* definition. */
private CalciteAssert.AssertQuery checkThatMaterialize(String materialize,
String query, String name, boolean existing, String model,
Function<ResultSet, Void> explainChecker, final RuleSet rules) {
try (final TryThreadLocal.Memo ignored = Prepare.THREAD_TRIM.push(true)) {
MaterializationService.setThreadLocal();
CalciteAssert.AssertQuery that = CalciteAssert.that()
.withMaterializations(model, existing, name, materialize)
.query(query)
.enableMaterializations(true);
// Add any additional rules required for the test
if (rules.iterator().hasNext()) {
that.withHook(Hook.PLANNER, new Function<RelOptPlanner, Void>() {
public Void apply(RelOptPlanner planner) {
for (RelOptRule rule : rules) {
planner.addRule(rule);
}
return null;
}
});
}
return that.explainMatches("", explainChecker);
}
}
示例9: testPrePopulated
import org.apache.calcite.prepare.Prepare; //导入依赖的package包/类
/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-761">[CALCITE-761]
* Pre-populated materializations</a>. */
@Test public void testPrePopulated() {
String q = "select \"deptno\" from \"emps\"";
try (final TryThreadLocal.Memo ignored = Prepare.THREAD_TRIM.push(true)) {
MaterializationService.setThreadLocal();
CalciteAssert.that()
.withMaterializations(
HR_FKUK_MODEL,
new Function<JsonBuilder, List<Object>>() {
public List<Object> apply(JsonBuilder builder) {
final Map<String, Object> map = builder.map();
map.put("table", "locations");
String sql = "select `deptno` as `empid`, '' as `name`\n"
+ "from `emps`";
final String sql2 = sql.replaceAll("`", "\"");
map.put("sql", sql2);
return ImmutableList.<Object>of(map);
}
})
.query(q)
.enableMaterializations(true)
.explainMatches("", CONTAINS_LOCATIONS)
.sameResultWithMaterializationsDisabled();
}
}
示例10: testMultiMaterializationMultiUsage
import org.apache.calcite.prepare.Prepare; //导入依赖的package包/类
@Test public void testMultiMaterializationMultiUsage() {
String q = "select *\n"
+ "from (select * from \"emps\" where \"empid\" < 300)\n"
+ "join (select \"deptno\", count(*) as c from \"emps\" group by \"deptno\") using (\"deptno\")";
try (final TryThreadLocal.Memo ignored = Prepare.THREAD_TRIM.push(true)) {
MaterializationService.setThreadLocal();
CalciteAssert.that()
.withMaterializations(HR_FKUK_MODEL,
"m0", "select \"deptno\", count(*) as c, sum(\"empid\") as s from \"emps\" group by \"deptno\"",
"m1", "select * from \"emps\" where \"empid\" < 500")
.query(q)
.enableMaterializations(true)
.explainContains("EnumerableTableScan(table=[[hr, m0]])")
.explainContains("EnumerableTableScan(table=[[hr, m1]])")
.sameResultWithMaterializationsDisabled();
}
}
示例11: testMultiMaterializationOnJoinQuery
import org.apache.calcite.prepare.Prepare; //导入依赖的package包/类
@Ignore("Creating mv for depts considering all its column throws exception")
@Test public void testMultiMaterializationOnJoinQuery() {
final String q = "select *\n"
+ "from \"emps\"\n"
+ "join \"depts\" using (\"deptno\") where \"empid\" < 300 "
+ "and \"depts\".\"deptno\" > 200";
try (final TryThreadLocal.Memo ignored = Prepare.THREAD_TRIM.push(true)) {
MaterializationService.setThreadLocal();
CalciteAssert.that()
.withMaterializations(HR_FKUK_MODEL,
"m0", "select * from \"emps\" where \"empid\" < 500",
"m1", "select * from \"depts\" where \"deptno\" > 100")
.query(q)
.enableMaterializations(true)
.explainContains("EnumerableTableScan(table=[[hr, m0]])")
.explainContains("EnumerableTableScan(table=[[hr, m1]])")
.sameResultWithMaterializationsDisabled();
}
}
示例12: TesterImpl
import org.apache.calcite.prepare.Prepare; //导入依赖的package包/类
protected TesterImpl(DiffRepository diffRepos, boolean enableDecorrelate,
boolean enableTrim, boolean enableExpand, boolean enableLateDecorrelate,
Function<RelDataTypeFactory, Prepare.CatalogReader>
catalogReaderFactory,
Function<RelOptCluster, RelOptCluster> clusterFactory,
SqlToRelConverter.Config config, SqlConformance conformance,
Context context) {
this.diffRepos = diffRepos;
this.enableDecorrelate = enableDecorrelate;
this.enableTrim = enableTrim;
this.enableExpand = enableExpand;
this.enableLateDecorrelate = enableLateDecorrelate;
this.catalogReaderFactory = catalogReaderFactory;
this.clusterFactory = clusterFactory;
this.config = config;
this.conformance = conformance;
this.context = context;
}
示例13: testTrimFieldsOver
import org.apache.calcite.prepare.Prepare; //导入依赖的package包/类
/** Tests that field-trimming creates a project near the table scan, in a
* query with windowed-aggregation. */
@Test public void testTrimFieldsOver() throws Exception {
try (final TryThreadLocal.Memo ignored = Prepare.THREAD_TRIM.push(true)) {
// The correct plan has a project on a filter on a project on a scan.
CalciteAssert.hr()
.query("select \"name\",\n"
+ " count(\"commission\") over (partition by \"deptno\") + 1\n"
+ "from \"hr\".\"emps\"\n"
+ "where \"empid\" > 10")
.convertContains(""
+ "LogicalProject(name=[$2], EXPR$1=[+(COUNT($3) OVER (PARTITION BY $1 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING), 1)])\n"
+ " LogicalFilter(condition=[>($0, 10)])\n"
+ " LogicalProject(empid=[$0], deptno=[$1], name=[$2], commission=[$4])\n"
+ " EnumerableTableScan(table=[[hr, emps]])\n");
}
}
示例14: testScalarSubQueryInCase
import org.apache.calcite.prepare.Prepare; //导入依赖的package包/类
@Test public void testScalarSubQueryInCase() {
try (final TryThreadLocal.Memo ignored = Prepare.THREAD_EXPAND.push(true)) {
CalciteAssert.hr()
.query("select e.\"name\",\n"
+ " (CASE e.\"deptno\"\n"
+ " WHEN (Select \"deptno\" from \"hr\".\"depts\" d\n"
+ " where d.\"deptno\" = e.\"deptno\")\n"
+ " THEN (Select d.\"name\" from \"hr\".\"depts\" d\n"
+ " where d.\"deptno\" = e.\"deptno\")\n"
+ " ELSE 'DepartmentNotFound' END) AS DEPTNAME\n"
+ "from \"hr\".\"emps\" e")
.returnsUnordered("name=Bill; DEPTNAME=Sales",
"name=Eric; DEPTNAME=DepartmentNotFound",
"name=Sebastian; DEPTNAME=Sales",
"name=Theodore; DEPTNAME=Sales");
}
}
示例15: deduceMonotonicity
import org.apache.calcite.prepare.Prepare; //导入依赖的package包/类
private static List<RelCollation> deduceMonotonicity(
Prepare.PreparingTable table) {
final List<RelCollation> collationList = Lists.newArrayList();
// Deduce which fields the table is sorted on.
int i = -1;
for (RelDataTypeField field : table.getRowType().getFieldList()) {
++i;
final SqlMonotonicity monotonicity =
table.getMonotonicity(field.getName());
if (monotonicity != SqlMonotonicity.NOT_MONOTONIC) {
final RelFieldCollation.Direction direction =
monotonicity.isDecreasing()
? RelFieldCollation.Direction.DESCENDING
: RelFieldCollation.Direction.ASCENDING;
collationList.add(
RelCollations.of(
new RelFieldCollation(i, direction)));
}
}
return collationList;
}