org.apache.calcite.rel.core.Project.getChildExps()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中org.apache.calcite.rel.core.Project.getChildExps()方法的一些代码示例,展示了Project.getChildExps()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.getChildExps()方法的具体详情如下:
包路径:org.apache.calcite.rel.core.Project
类名称:Project
方法名:getChildExps

Project.getChildExps介绍

暂无

代码示例

代码示例来源:origin: apache/hive

@Override
public boolean matches(RelOptRuleCall call) {
 // Currently we do not support merging windowing functions with other
 // windowing functions i.e. embedding windowing functions within each
 // other
 final Project topProject = call.rel(0);
 final Project bottomProject = call.rel(1);
 for (RexNode expr : topProject.getChildExps()) {
  if (expr instanceof RexOver) {
   Set<Integer> positions = HiveCalciteUtil.getInputRefs(expr);
   for (int pos : positions) {
    if (bottomProject.getChildExps().get(pos) instanceof RexOver) {
     return false;
    }
   }
  }
 }
 return super.matches(call);
}

代码示例来源:origin: apache/incubator-druid

/**
 * Translate a field access, possibly through a projection, to an underlying Druid dataSource.
 *
 * @param rowSignature row signature of underlying Druid dataSource
 * @param project      projection, or null
 * @param fieldNumber  number of the field to access
 *
 * @return row expression
 */
public static RexNode fromFieldAccess(
  final RowSignature rowSignature,
  final Project project,
  final int fieldNumber
)
{
 if (project == null) {
  // I don't think the factory impl matters here.
  return RexInputRef.of(fieldNumber, rowSignature.getRelDataType(new JavaTypeFactoryImpl()));
 } else {
  return project.getChildExps().get(fieldNumber);
 }
}

代码示例来源:origin: apache/drill

@Override
public boolean matches(RelOptRuleCall call) {
 // Currently we do not support merging windowing functions with other
 // windowing functions i.e. embedding windowing functions within each
 // other
 final Project topProject = call.rel(0);
 final Project bottomProject = call.rel(1);
 for (RexNode expr : topProject.getChildExps()) {
  if (expr instanceof RexOver) {
   Set<Integer> positions = HiveCalciteUtil.getInputRefs(expr);
   for (int pos : positions) {
    if (bottomProject.getChildExps().get(pos) instanceof RexOver) {
     return false;
    }
   }
  }
 }
 return super.matches(call);
}

代码示例来源:origin: apache/hive

protected static String generateInvalidSchemaMessage(Project topLevelProj,
  List<FieldSchema> resultSchema, int fieldsForOB) {
 String errorDesc = "Result Schema didn't match Calcite Optimized Op Tree; schema: ";
 for (FieldSchema fs : resultSchema) {
  errorDesc += "[" + fs.getName() + ":" + fs.getType() + "], ";
 }
 errorDesc += " projection fields: ";
 for (RexNode exp : topLevelProj.getChildExps()) {
  errorDesc += "[" + exp.toString() + ":" + exp.getType() + "], ";
 }
 if (fieldsForOB != 0) {
  errorDesc += fieldsForOB + " fields removed due to ORDER BY  ";
 }
 return errorDesc.substring(0, errorDesc.length() - 2);
}

代码示例来源:origin: apache/incubator-druid

@Override
public boolean matches(final RelOptRuleCall call)
{
 final Aggregate aggregate = call.rel(0);
 final Project project = call.rel(1);
 if (aggregate.indicator || aggregate.getGroupSets().size() != 1) {
  return false;
 }
 for (AggregateCall aggregateCall : aggregate.getAggCallList()) {
  if (isOneArgAggregateCall(aggregateCall)
    && isThreeArgCase(project.getChildExps().get(Iterables.getOnlyElement(aggregateCall.getArgList())))) {
   return true;
  }
 }
 return false;
}

代码示例来源:origin: apache/hive

public RelNode align(Project rel, List<RelFieldCollation> collations) {
 // 1) We extract the collations indices
 boolean containsWindowing = false;
 for (RexNode childExp : rel.getChildExps()) {
  if (childExp instanceof RexOver) {
   // TODO: support propagation for partitioning/ordering in windowing
   containsWindowing = true;
   break;
  }
 }
 ImmutableList.Builder<RelFieldCollation> propagateCollations = ImmutableList.builder();
 if (!containsWindowing) {
  for (RelFieldCollation c : collations) {
   RexNode rexNode = rel.getChildExps().get(c.getFieldIndex());
   if (rexNode instanceof RexInputRef) {
    int newIdx = ((RexInputRef) rexNode).getIndex();
    propagateCollations.add(c.copy((newIdx)));
   }
  }
 }
 // 2) We propagate
 final RelNode child = dispatchAlign(rel.getInput(), propagateCollations.build());
 // 3) Return new Project
 return rel.copy(rel.getTraitSet(), ImmutableList.of(child));
}

代码示例来源:origin: apache/drill

protected static String generateInvalidSchemaMessage(Project topLevelProj,
  List<FieldSchema> resultSchema, int fieldsForOB) {
 String errorDesc = "Result Schema didn't match Calcite Optimized Op Tree; schema: ";
 for (FieldSchema fs : resultSchema) {
  errorDesc += "[" + fs.getName() + ":" + fs.getType() + "], ";
 }
 errorDesc += " projection fields: ";
 for (RexNode exp : topLevelProj.getChildExps()) {
  errorDesc += "[" + exp.toString() + ":" + exp.getType() + "], ";
 }
 if (fieldsForOB != 0) {
  errorDesc += fieldsForOB + " fields removed due to ORDER BY  ";
 }
 return errorDesc.substring(0, errorDesc.length() - 2);
}

代码示例来源:origin: apache/incubator-druid

for (final RexNode rexNode : project.getChildExps()) {
 final DruidExpression expression = Expressions.toDruidExpression(
   plannerContext,
    expression.toVirtualColumn(
      virtualColumnName,
      Calcites.getValueTypeForSqlTypeName(project.getChildExps().get(i).getType().getSqlTypeName()),
      plannerContext.getExprMacroTable()

代码示例来源:origin: apache/hive

private static RexCall adjustOBSchema(RexCall obyExpr, Project obChild,
    List<FieldSchema> resultSchema) {
 int a = -1;
 List<RexNode> operands = new ArrayList<>();
 for (int k = 0; k < obyExpr.operands.size(); k++) {
  RexNode rn = obyExpr.operands.get(k);
  for (int j = 0; j < resultSchema.size(); j++) {
   if( obChild.getChildExps().get(j).toString().equals(rn.toString())) {
    a = j;
    break;
   }
  }
  if (a != -1) {
   operands.add(new RexInputRef(a, rn.getType()));
  } else {
   if (rn instanceof RexCall) {
    operands.add(adjustOBSchema((RexCall)rn, obChild, resultSchema));
   } else {
    operands.add(rn);
   }
  }
  a = -1;
 }
 return (RexCall) obChild.getCluster().getRexBuilder().makeCall(
     obyExpr.getType(), obyExpr.getOperator(), operands);
}

代码示例来源:origin: apache/incubator-druid

cost += COST_PER_COLUMN * partialQuery.getSelectProject().getChildExps().size();
cost += COST_PER_COLUMN * partialQuery.getAggregateProject().getChildExps().size();
cost += COST_PER_COLUMN * partialQuery.getSortProject().getChildExps().size();

代码示例来源:origin: apache/incubator-druid

for (final RexNode postAggregatorRexNode : project.getChildExps()) {

代码示例来源:origin: apache/hive

@Override
public RelOptMaterialization apply(RelOptMaterialization materialization) {
 final RelNode viewScan = materialization.tableRel;
 final RelNode newViewScan;
 if (viewScan instanceof Project) {
  // There is a Project on top (due to nullability)
  final Project pq = (Project) viewScan;
  newViewScan = HiveProject.create(optCluster, copyNodeScan(pq.getInput()),
    pq.getChildExps(), pq.getRowType(), Collections.<RelCollation> emptyList());
 } else {
  newViewScan = copyNodeScan(viewScan);
 }
 return new RelOptMaterialization(newViewScan, materialization.queryRel, null,
   materialization.qualifiedTableName);
}

代码示例来源:origin: apache/hive

private void fetchColStats(RelNode key, TableScan tableAccessRel, ImmutableBitSet fieldsUsed,
  Set<RelDataTypeField> extraFields) {
 final List<Integer> iRefSet = Lists.newArrayList();
 if (key instanceof Project) {
  final Project project = (Project) key;
  for (RexNode rx : project.getChildExps()) {
   iRefSet.addAll(HiveCalciteUtil.getInputRefs(rx));
  }
 } else {
  final int fieldCount = tableAccessRel.getRowType().getFieldCount();
  if (fieldsUsed.equals(ImmutableBitSet.range(fieldCount)) && extraFields.isEmpty()) {
   // get all cols
   iRefSet.addAll(ImmutableBitSet.range(fieldCount).asList());
  }
 }
 //Remove any virtual cols
 if (tableAccessRel instanceof HiveTableScan) {
  iRefSet.removeAll(((HiveTableScan)tableAccessRel).getVirtualCols());
 }
 if (!iRefSet.isEmpty()) {
  final RelOptTable table = tableAccessRel.getTable();
  if (table instanceof RelOptHiveTable) {
   ((RelOptHiveTable) table).getColStat(iRefSet, true);
   LOG.debug("Got col stats for {} in {}", iRefSet,
     tableAccessRel.getTable().getQualifiedName());
  }
 }
}

代码示例来源:origin: apache/incubator-druid

listBuilder.add(leftPartialQuery.getSelectProject().getChildExps().get(key));

代码示例来源:origin: apache/hive

@Override public void onMatch(RelOptRuleCall call) {
  final Project project = call.rel(0);
  final Join join = call.rel(1);
  final RelNode left = call.rel(2);
  final Aggregate aggregate = call.rel(3);
  final ImmutableBitSet topRefs =
    RelOptUtil.InputFinder.bits(project.getChildExps(), null);
  perform(call, topRefs, project, join, left, aggregate);
 }
}

代码示例来源:origin: apache/hive

public void onMatch(RelOptRuleCall call) {
 final Project topProject = call.rel(0);
 final Project bottomProject = call.rel(1);
 // If top project does not reference any column at the bottom project,
 // we can just remove botton project
 final ImmutableBitSet topRefs =
   RelOptUtil.InputFinder.bits(topProject.getChildExps(), null);
 if (topRefs.isEmpty()) {
  RelBuilder relBuilder = call.builder();
  relBuilder.push(bottomProject.getInput());
  relBuilder.project(topProject.getChildExps());
  call.transformTo(relBuilder.build());
  return;
 }
 super.onMatch(call);
}

代码示例来源:origin: apache/hive

public Result translate(Project e) {
 // This variant is for the top project as we want to keep
 // the column aliases instead of producing STAR
 Result x = visitChild(0, e.getInput());
 parseCorrelTable(e, x);
 final Builder builder =
   x.builder(e, Clause.SELECT);
 final List<SqlNode> selectList = new ArrayList<>();
 for (RexNode ref : e.getChildExps()) {
  SqlNode sqlExpr = builder.context.toSql(null, ref);
  addSelect(selectList, sqlExpr, e.getRowType());
 }
 builder.setSelect(new SqlNodeList(selectList, POS));
 return builder.result();
}

代码示例来源:origin: apache/incubator-druid

final Aggregate aggregate = call.rel(1);
final ImmutableBitSet projectBits = RelOptUtil.InputFinder.bits(project.getChildExps(), null);
     .push(newAggregate)
     .project(fixUpProjects)
     .project(project.getChildExps())
     .build()
 );

代码示例来源:origin: apache/hive

public void onMatch(RelOptRuleCall call) {
 final Project project = call.rel(0);
 final Filter filter = call.rel(1);
 final RelBuilder builder = call.builder();
 List<RexNode> projects = project.getChildExps();
 List<RexNode> newProjects = rewriteProjects(projects, filter.getCondition(), builder);
 if (newProjects == null) {
  return;
 }
 RelNode newProjRel = builder.push(filter)
     .project(newProjects, project.getRowType().getFieldNames()).build();
 call.transformTo(newProjRel);
}

代码示例来源:origin: apache/drill

public void onMatch(RelOptRuleCall call) {
 final Project project = call.rel(0);
 final Filter filter = call.rel(1);
 final RelBuilder builder = call.builder();
 List<RexNode> projects = project.getChildExps();
 List<RexNode> newProjects = rewriteProjects(projects, filter.getCondition(), builder);
 if (newProjects == null) {
  return;
 }
 RelNode newProjRel = builder.push(filter)
     .project(newProjects, project.getRowType().getFieldNames()).build();
 call.transformTo(newProjRel);
}

相关文章