• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Prepare类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.calcite.prepare.Prepare的典型用法代码示例。如果您正苦于以下问题:Java Prepare类的具体用法?Java Prepare怎么用?Java Prepare使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Prepare类属于org.apache.calcite.prepare包,在下文中一共展示了Prepare类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:SqlToRelConverter.java


示例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
    }
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:23,代码来源:JdbcRules.java


示例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();
}
 
开发者ID:apache,项目名称:kylin,代码行数:23,代码来源:SqlToRelConverter.java


示例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
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:JdbcRules.java


示例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);
}
 
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:SqlToRelConverter.java


示例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);
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:SqlValidatorImpl.java


示例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;
}
 
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:SqlValidatorUtil.java


示例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);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:28,代码来源:MaterializationTest.java


示例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();
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:28,代码来源:MaterializationTest.java


示例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();
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:MaterializationTest.java


示例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();
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:MaterializationTest.java


示例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;
}
 
开发者ID:apache,项目名称:calcite,代码行数:19,代码来源:SqlToRelTestBase.java


示例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");
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:JdbcTest.java


示例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");
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:JdbcTest.java


示例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;
}
 
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:MockCatalogReader.java


示例16: convert

import org.apache.calcite.prepare.Prepare; //导入依赖的package包/类
@Override
public RelNode convert(RelNode rel) {
  final TableModify tableModify = (TableModify) rel;
  final RelNode input = tableModify.getInput();

  final RelOptCluster cluster = tableModify.getCluster();
  final RelTraitSet traitSet = tableModify.getTraitSet().replace(BeamLogicalConvention.INSTANCE);
  final RelOptTable relOptTable = tableModify.getTable();
  final Prepare.CatalogReader catalogReader = tableModify.getCatalogReader();
  final RelNode convertedInput = convert(input,
      input.getTraitSet().replace(BeamLogicalConvention.INSTANCE));
  final TableModify.Operation operation = tableModify.getOperation();
  final List<String> updateColumnList = tableModify.getUpdateColumnList();
  final List<RexNode> sourceExpressionList = tableModify.getSourceExpressionList();
  final boolean flattened = tableModify.isFlattened();

  final Table table = tableModify.getTable().unwrap(Table.class);

  switch (table.getJdbcTableType()) {
  case TABLE:
  case STREAM:
    if (operation != TableModify.Operation.INSERT) {
      throw new UnsupportedOperationException(
          String.format("Streams doesn't support %s modify operation", operation));
    }
    return new BeamIOSinkRel(cluster, traitSet,
        relOptTable, catalogReader, convertedInput, operation, updateColumnList,
        sourceExpressionList, flattened);
  default:
    throw new IllegalArgumentException(
        String.format("Unsupported table type: %s", table.getJdbcTableType()));
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:34,代码来源:BeamIOSinkRule.java


示例17: handler

import org.apache.calcite.prepare.Prepare; //导入依赖的package包/类
private static Function<Pair<List<Prepare.Materialization>, Holder<Program>>, Void> handler(
    final boolean bushy, final int minJoinCount) {
  return new Function<Pair<List<Prepare.Materialization>, Holder<Program>>,
      Void>() {
    public Void apply(
        Pair<List<Prepare.Materialization>, Holder<Program>> pair) {
      pair.right.set(
          Programs.sequence(
              Programs.heuristicJoinOrder(Programs.RULE_SET, bushy,
                  minJoinCount),
              Programs.CALC_PROGRAM));
      return null;
    }
  };
}
 
开发者ID:apache,项目名称:calcite,代码行数:16,代码来源:TpcdsTest.java


示例18: toModificationRel

import org.apache.calcite.prepare.Prepare; //导入依赖的package包/类
public TableModify toModificationRel(
    RelOptCluster cluster,
    RelOptTable table,
    Prepare.CatalogReader catalogReader,
    RelNode child,
    TableModify.Operation operation,
    List<String> updateColumnList,
    List<RexNode> sourceExpressionList,
    boolean flattened) {
  return LogicalTableModify.create(table, catalogReader, child, operation,
      updateColumnList, sourceExpressionList, flattened);
}
 
开发者ID:apache,项目名称:calcite,代码行数:13,代码来源:SqlCreateTable.java


示例19: query

import org.apache.calcite.prepare.Prepare; //导入依赖的package包/类
/** Gathers a list of all materialized tables known within a given root
 * schema. (Each root schema defines a disconnected namespace, with no overlap
 * with the current schema. Especially in a test run, the contents of two
 * root schemas may look similar.) */
public List<Prepare.Materialization> query(CalciteSchema rootSchema) {
  final List<Prepare.Materialization> list = new ArrayList<>();
  for (MaterializationActor.Materialization materialization
      : actor.keyMap.values()) {
    if (materialization.rootSchema.schema == rootSchema.schema
        && materialization.materializedTable != null) {
      list.add(
          new Prepare.Materialization(materialization.materializedTable,
              materialization.sql, materialization.viewSchemaPath));
    }
  }
  return list;
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:MaterializationService.java


示例20: MutableTableModify

import org.apache.calcite.prepare.Prepare; //导入依赖的package包/类
private MutableTableModify(RelDataType rowType, MutableRel input,
    RelOptTable table, Prepare.CatalogReader catalogReader,
    Operation operation, List<String> updateColumnList,
    List<RexNode> sourceExpressionList, boolean flattened) {
  super(MutableRelType.TABLE_MODIFY, rowType, input);
  this.table = table;
  this.catalogReader = catalogReader;
  this.operation = operation;
  this.updateColumnList = updateColumnList;
  this.sourceExpressionList = sourceExpressionList;
  this.flattened = flattened;
}
 
开发者ID:apache,项目名称:calcite,代码行数:13,代码来源:MutableTableModify.java



注:本文中的org.apache.calcite.prepare.Prepare类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Operation类代码示例发布时间:2022-05-22
下一篇:
Java AutoWrap类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap