private Statistic buildStatistic() { if (stats != null || primaryKey == -1) { return stats; } Direction dir = primaryKeyMonotonicity == INCREASING ? ASCENDING : DESCENDING; RelFieldCollation collation = new RelFieldCollation(primaryKey, dir, NullDirection.UNSPECIFIED); return Statistics.of(fields.size(), ImmutableList.of(ImmutableBitSet.of(primaryKey)), ImmutableList.of(RelCollations.of(collation))); }
/** * Empty relationship can be expressed in many different ways, e.g., * filter(cond=false), empty LogicalValues(), etc. Calcite default implementation * uses empty LogicalValues(); however, currently there is not an equivalent to * this expression in Hive. Thus, we use limit 0, since Hive already includes * optimizations that will do early pruning of the result tree when it is found, * e.g., GlobalLimitOptimizer. */ public HiveSubQRemoveRelBuilder empty() { final RelNode input = build(); final RelNode sort = HiveRelFactories.HIVE_SORT_FACTORY.createSort( input, RelCollations.of(), null, literal(0)); return this.push(sort); }
/** * Empty relationship can be expressed in many different ways, e.g., * filter(cond=false), empty LogicalValues(), etc. Calcite default implementation * uses empty LogicalValues(); however, currently there is not an equivalent to * this expression in Hive. Thus, we use limit 0, since Hive already includes * optimizations that will do early pruning of the result tree when it is found, * e.g., GlobalLimitOptimizer. */ @Override public RelBuilder empty() { final RelNode input = build(); final RelNode sort = HiveRelFactories.HIVE_SORT_FACTORY.createSort( input, RelCollations.of(), null, literal(0)); return this.push(sort); }
/** * Empty relationship can be expressed in many different ways, e.g., * filter(cond=false), empty LogicalValues(), etc. Calcite default implementation * uses empty LogicalValues(); however, currently there is not an equivalent to * this expression in Hive. Thus, we use limit 0, since Hive already includes * optimizations that will do early pruning of the result tree when it is found, * e.g., GlobalLimitOptimizer. */ @Override public RelBuilder empty() { final RelNode input = build(); final RelNode sort = HiveRelFactories.HIVE_SORT_FACTORY.createSort( input, RelCollations.of(), null, literal(0)); return this.push(sort); }
/** * Empty relationship can be expressed in many different ways, e.g., * filter(cond=false), empty LogicalValues(), etc. Calcite default implementation * uses empty LogicalValues(); however, currently there is not an equivalent to * this expression in Hive. Thus, we use limit 0, since Hive already includes * optimizations that will do early pruning of the result tree when it is found, * e.g., GlobalLimitOptimizer. */ public HiveSubQRemoveRelBuilder empty() { final RelNode input = build(); final RelNode sort = HiveRelFactories.HIVE_SORT_FACTORY.createSort( input, RelCollations.of(), null, literal(0)); return this.push(sort); }
relBuilder.project(Pair.left(newChildExprs), Pair.right(newChildExprs)); final ImmutableList<RexNode> sortFields = relBuilder.fields(RelCollations.of(fieldCollations)); relBuilder.sortLimit(sort.offset == null ? -1 : RexLiteral.intValue(sort.offset), sort.fetch == null ? -1 : RexLiteral.intValue(sort.fetch), sortFields);
relBuilder.project(Pair.left(newChildExprs), Pair.right(newChildExprs)); final ImmutableList<RexNode> sortFields = relBuilder.fields(RelCollations.of(fieldCollations)); relBuilder.sortLimit(sort.offset == null ? -1 : RexLiteral.intValue(sort.offset), sort.fetch == null ? -1 : RexLiteral.intValue(sort.fetch), sortFields);
sortFactory.createSort(build(), RelCollations.of(fieldCollations), offsetNode, fetchNode); push(sort);
sortFactory.createSort(build(), RelCollations.of(fieldCollations), offsetNode, fetchNode); push(sort);
/** * Creates a list containing one collation containing one field. */ public static List<RelCollation> createSingleton(int fieldIndex) { return ImmutableList.of(of(fieldIndex)); }
@Deprecated // to be removed before 2.0 public static RelCollation of(List<RelFieldCollation> fieldCollations) { return RelCollations.of(fieldCollations); }
/** * Creates a list containing one collation containing one field. */ public static List<RelCollation> createSingleton(int fieldIndex) { return ImmutableList.of(of(fieldIndex)); }
public RelCollation toCollation( List<Map<String, Object>> jsonFieldCollations) { final List<RelFieldCollation> fieldCollations = new ArrayList<>(); for (Map<String, Object> map : jsonFieldCollations) { fieldCollations.add(toFieldCollation(map)); } return RelCollations.of(fieldCollations); }
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())); }
public RelCollation toCollation( List<Map<String, Object>> jsonFieldCollations) { final List<RelFieldCollation> fieldCollations = new ArrayList<>(); for (Map<String, Object> map : jsonFieldCollations) { fieldCollations.add(toFieldCollation(map)); } return RelCollations.of(fieldCollations); }
private RelCollation getCollation(List<Integer> keys) { List<RelFieldCollation> fields = Lists.newArrayList(); for (int key : keys) { fields.add(new RelFieldCollation(key)); } return RelCollations.of(fields); }
private RelCollation getCollation(DrillAggregateRel rel) { List<RelFieldCollation> fields = Lists.newArrayList(); for (int group : BitSets.toIter(rel.getGroupSet())) { fields.add(new RelFieldCollation(group)); } return RelCollations.of(fields); } }
private static RelCollation collation(int... ordinals) { final List<RelFieldCollation> list = new ArrayList<>(); for (int ordinal : ordinals) { list.add(new RelFieldCollation(ordinal)); } return RelCollations.of(list); } }
/** Creates a copy of this collation that changes the ordinals of input * fields. */ public static RelCollation permute(RelCollation collation, Mappings.TargetMapping mapping) { return of( Util.transform(collation.getFieldCollations(), fc -> fc.copy(mapping.getTarget(fc.getFieldIndex())))); } }