public ImmutableList<RelCollation> collations(HiveAggregate aggregate, RelMetadataQuery mq) { // Compute collations ImmutableList.Builder<RelFieldCollation> collationListBuilder = new ImmutableList.Builder<RelFieldCollation>(); for (int pos : aggregate.getGroupSet().asList()) { final RelFieldCollation fieldCollation = new RelFieldCollation(pos); collationListBuilder.add(fieldCollation); } // Return aggregate collations return ImmutableList.of( RelCollationTraitDef.INSTANCE.canonize( new HiveRelCollation(collationListBuilder.build()))); }
public RelDistribution distribution(HiveAggregate aggregate, RelMetadataQuery mq) { return new HiveRelDistribution(RelDistribution.Type.HASH_DISTRIBUTED, aggregate.getGroupSet().asList()); }
public RelDistribution distribution(HiveAggregate aggregate, RelMetadataQuery mq) { return new HiveRelDistribution(RelDistribution.Type.HASH_DISTRIBUTED, aggregate.getGroupSet().asList()); }
public boolean isBucketedInput() { final RelMetadataQuery mq = this.getInput().getCluster().getMetadataQuery(); return mq.distribution(this).getKeys(). containsAll(groupSet.asList()); }
public boolean isBucketedInput() { return RelMetadataQuery.instance().distribution(this.getInput()).getKeys(). containsAll(groupSet.asList()); }
ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, final List<AggregateCall> aggCalls) { final List<Integer> groupList = groupSet.asList(); assert groupList.size() == groupSet.cardinality(); final RelDataTypeFactory.FieldInfoBuilder builder = typeFactory.builder();
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()); } } }
ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, final List<AggregateCall> aggCalls) { final List<Integer> groupList = groupSet.asList(); assert groupList.size() == groupSet.cardinality(); final RelDataTypeFactory.FieldInfoBuilder builder = typeFactory.builder();
for (ImmutableBitSet grpSet : lstGrpSet) { bitmap = 0; for (Integer bitIdx : grpSet.asList()) { bitmap = SemanticAnalyzer.setBit(bitmap, bitIdx);
if (fieldsUsed.equals(ImmutableBitSet.range(fieldCount)) && extraFields.isEmpty()) { iRefSet.addAll(ImmutableBitSet.range(fieldCount).asList());
@Override public void onMatch(RelOptRuleCall call) { final Filter fil = call.rel(0); final TableScan rel = call.rel(1); // Add identity RelBuilder relBuilder = call.builder(); relBuilder.push(rel); List<RexNode> identityFields = relBuilder.fields( ImmutableBitSet.range(0, rel.getRowType().getFieldCount()).asList()); RelNode newRel = relBuilder .project(identityFields, ImmutableList.<String>of(), true) .build(); call.transformTo(fil.copy(fil.getTraitSet(), ImmutableList.of(newRel))); }
for (final int colIndex : constrainedTargetColumns.asList()) { final String colName = tableFields.get(colIndex).getName(); final RelDataTypeField targetField = tableIndexToTargetField.get(colIndex);
public ImmutableList<RelCollation> collations(HiveAggregate aggregate, RelMetadataQuery mq) { // Compute collations ImmutableList.Builder<RelFieldCollation> collationListBuilder = new ImmutableList.Builder<RelFieldCollation>(); for (int pos : aggregate.getGroupSet().asList()) { final RelFieldCollation fieldCollation = new RelFieldCollation(pos); collationListBuilder.add(fieldCollation); } // Return aggregate collations return ImmutableList.of( RelCollationTraitDef.INSTANCE.canonize( new HiveRelCollation(collationListBuilder.build()))); }
@Override public void onMatch(RelOptRuleCall call) { final Join join = call.rel(0); final HepRelVertex root = (HepRelVertex) call.getPlanner().getRoot(); if (root.getCurrentRel() != join) { // Bail out return; } // The join is the root, but we should always end up with a Project operator // on top. We will add it. RelBuilder relBuilder = call.builder(); relBuilder.push(join); List<RexNode> identityFields = relBuilder.fields( ImmutableBitSet.range(0, join.getRowType().getFieldCount()).asList()); relBuilder.project(identityFields, ImmutableList.<String>of(), true); call.transformTo(relBuilder.build()); }
final List<Integer> targetGroupList = target.getGroupSet().asList(); for (int c : query.getGroupSet()) { int c2 = targetGroupList.indexOf(c);
bottomGroupSet.addAll(aggregate.getGroupSet().asList()); for (AggregateCall aggCall : originalAggCalls) { if (aggCall.isDistinct()) {
if (!newKeys.equals(newGroupSet.asList())) { final List<Integer> posList = Lists.newArrayList(); for (int newKey : newKeys) {
final List<Integer> aggregateKeys = aggregate.getGroupSet().asList(); for (int key : joinInfo.rightKeys) { newRightKeyBuilder.add(aggregateKeys.get(key));
final RelBuilder relBuilder = call.builder(); RelNode newRightInput = relBuilder.project(relBuilder.push(rightAggregate.getInput()). fields(rightAggregate.getGroupSet().asList())).build(); RelNode newSemiJoin = call.builder().push(left).push(newRightInput) .semiJoin(semijoin.getCondition()).build();
final List<Integer> aggregateKeys = aggregate.getGroupSet().asList(); for (int key : joinInfo.rightKeys) { newRightKeyBuilder.add(aggregateKeys.get(key));