当前位置: 首页>>代码示例>>Java>>正文


Java Prepare类代码示例

本文整理汇总了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();
}
 
开发者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


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