@Override public HiveSortLimit copy(RelTraitSet traitSet, RelNode newInput, RelCollation newCollation, RexNode offset, RexNode fetch) { // TODO: can we blindly copy sort trait? What if inputs changed and we // are now sorting by different cols RelCollation canonizedCollation = traitSet.canonize(newCollation); HiveSortLimit sortLimit = new HiveSortLimit(getCluster(), traitSet, newInput, canonizedCollation, offset, fetch); sortLimit.setRuleCreated(ruleCreated); return sortLimit; }
@Override public HiveSortLimit copy(RelTraitSet traitSet, RelNode newInput, RelCollation newCollation, RexNode offset, RexNode fetch) { // TODO: can we blindly copy sort trait? What if inputs changed and we // are now sorting by different cols RelCollation canonizedCollation = traitSet.canonize(newCollation); HiveSortLimit sortLimit = new HiveSortLimit(getCluster(), traitSet, newInput, canonizedCollation, offset, fetch); sortLimit.setRuleCreated(ruleCreated); return sortLimit; }
private RelNode genLimitLogicalPlan(QB qb, RelNode srcRel) throws SemanticException { HiveRelNode sortRel = null; QBParseInfo qbp = getQBParseInfo(qb); SimpleEntry<Integer,Integer> entry = qbp.getDestToLimit().get(qbp.getClauseNames().iterator().next()); Integer offset = (entry == null) ? 0 : entry.getKey(); Integer fetch = (entry == null) ? null : entry.getValue(); if (fetch != null) { RexNode offsetRN = cluster.getRexBuilder().makeExactLiteral(BigDecimal.valueOf(offset)); RexNode fetchRN = cluster.getRexBuilder().makeExactLiteral(BigDecimal.valueOf(fetch)); RelTraitSet traitSet = cluster.traitSetOf(HiveRelNode.CONVENTION); RelCollation canonizedCollation = traitSet.canonize(RelCollations.EMPTY); sortRel = new HiveSortLimit(cluster, traitSet, srcRel, canonizedCollation, offsetRN, fetchRN); RowResolver inputRR = relToHiveRR.get(srcRel); RowResolver outputRR = inputRR.duplicate(); ImmutableMap<String, Integer> hiveColNameCalcitePosMap = buildHiveToCalciteColumnMap( outputRR, sortRel); relToHiveRR.put(sortRel, outputRR); relToHiveColNameCalcitePosMap.put(sortRel, hiveColNameCalcitePosMap); } return sortRel; }
private RelNode genLimitLogicalPlan(QB qb, RelNode srcRel) throws SemanticException { HiveRelNode sortRel = null; QBParseInfo qbp = getQBParseInfo(qb); SimpleEntry<Integer,Integer> entry = qbp.getDestToLimit().get(qbp.getClauseNames().iterator().next()); Integer offset = (entry == null) ? 0 : entry.getKey(); Integer fetch = (entry == null) ? null : entry.getValue(); if (fetch != null) { RexNode offsetRN = cluster.getRexBuilder().makeExactLiteral(BigDecimal.valueOf(offset)); RexNode fetchRN = cluster.getRexBuilder().makeExactLiteral(BigDecimal.valueOf(fetch)); RelTraitSet traitSet = cluster.traitSetOf(HiveRelNode.CONVENTION); RelCollation canonizedCollation = traitSet.canonize(RelCollations.EMPTY); sortRel = new HiveSortLimit(cluster, traitSet, srcRel, canonizedCollation, offsetRN, fetchRN); RowResolver outputRR = new RowResolver(); if (!RowResolver.add(outputRR, relToHiveRR.get(srcRel))) { throw new CalciteSemanticException( "Duplicates detected when adding columns to RR: see previous message", UnsupportedFeature.Duplicates_in_RR); } ImmutableMap<String, Integer> hiveColNameCalcitePosMap = buildHiveToCalciteColumnMap( outputRR, sortRel); relToHiveRR.put(sortRel, outputRR); relToHiveColNameCalcitePosMap.put(sortRel, hiveColNameCalcitePosMap); } return sortRel; }
RelCollation newCollation = traitSet.canonize(RelCollationImpl.of(fieldCollations));
RelCollation canonizedCollation = traitSet.canonize(RelCollationImpl.of(fieldCollations)); sortRel = new HiveSortLimit(cluster, traitSet, obInputRel, canonizedCollation, null, null);
RelCollation canonizedCollation = traitSet.canonize(RelCollationImpl.of(fieldCollations)); sortRel = new HiveSortLimit(cluster, traitSet, obInputRel, canonizedCollation, null, null);
private static RelCollation getCollation(RelTraitSet set, List<Integer> keys) { return set.canonize(RelCollations.of(FluentIterable.from(keys) .transform(new Function<Integer, RelFieldCollation>() { @Override public RelFieldCollation apply(Integer input) { return new RelFieldCollation(input); } }).toList())); }
@Override public HiveSort copy(RelTraitSet traitSet, RelNode newInput, RelCollation newCollation, RexNode offset, RexNode fetch) { // TODO: can we blindly copy sort trait? What if inputs changed and we // are now sorting by different cols RelCollation canonizedCollation = traitSet.canonize(newCollation); return new HiveSort(getCluster(), traitSet, newInput, canonizedCollation, offset, fetch); }
private RelNode genLimitLogicalPlan(QB qb, RelNode srcRel) throws SemanticException { HiveRelNode sortRel = null; QBParseInfo qbp = getQBParseInfo(qb); Integer limit = qbp.getDestToLimit().get(qbp.getClauseNames().iterator().next()); if (limit != null) { RexNode fetch = cluster.getRexBuilder().makeExactLiteral(BigDecimal.valueOf(limit)); RelTraitSet traitSet = cluster.traitSetOf(HiveRelNode.CONVENTION); RelCollation canonizedCollation = traitSet.canonize(RelCollations.EMPTY); sortRel = new HiveSort(cluster, traitSet, srcRel, canonizedCollation, null, fetch); RowResolver outputRR = new RowResolver(); if (!RowResolver.add(outputRR, relToHiveRR.get(srcRel))) { throw new CalciteSemanticException( "Duplicates detected when adding columns to RR: see previous message", UnsupportedFeature.Duplicates_in_RR); } ImmutableMap<String, Integer> hiveColNameCalcitePosMap = buildHiveToCalciteColumnMap( outputRR, sortRel); relToHiveRR.put(sortRel, outputRR); relToHiveColNameCalcitePosMap.put(sortRel, hiveColNameCalcitePosMap); } return sortRel; }
final RelTrait canonizedTrait = canonize(trait); assert canonizedTrait != null; List<RelTrait> newTraits;
final RelTrait canonizedTrait = canonize(trait); assert canonizedTrait != null; List<RelTrait> newTraits;
/** * Replaces an existing RelTrait in the set. * Returns a different trait set; does not modify this trait set. * * @param index 0-based index into ordered RelTraitSet * @param trait the new RelTrait * @return the old RelTrait at the index */ public RelTraitSet replace(int index, RelTrait trait) { assert traits[index].getTraitDef() == trait.getTraitDef() : "RelTrait has different RelTraitDef than replacement"; RelTrait canonizedTrait = canonize(trait); if (traits[index] == canonizedTrait) { return this; } RelTrait[] newTraits = traits.clone(); newTraits[index] = canonizedTrait; return cache.getOrAdd(new RelTraitSet(cache, newTraits)); }
/** * Replaces an existing RelTrait in the set. * Returns a different trait set; does not modify this trait set. * * @param index 0-based index into ordered RelTraitSet * @param trait the new RelTrait * @return the old RelTrait at the index */ public RelTraitSet replace(int index, RelTrait trait) { assert traits[index].getTraitDef() == trait.getTraitDef() : "RelTrait has different RelTraitDef than replacement"; RelTrait canonizedTrait = canonize(trait); if (traits[index] == canonizedTrait) { return this; } RelTrait[] newTraits = traits.clone(); newTraits[index] = canonizedTrait; return cache.getOrAdd(new RelTraitSet(cache, newTraits)); }
collationList); final RelCollation collation = cluster.traitSet().canonize(RelCollations.of(collationList));
collationList); final RelCollation collation = cluster.traitSet().canonize(RelCollations.of(collationList));
collationList); final RelCollation collation = cluster.traitSet().canonize(RelCollations.of(collationList));
collationList); final RelCollation collation = cluster.traitSet().canonize(RelCollations.of(collationList));
cluster.traitSet().canonize( RexUtil.apply(map, sort.getCollation())); final Sort newSort =
cluster.traitSet().canonize( RexUtil.apply(map, sort.getCollation())); final Sort newSort =