Java Code Examples for org.apache.calcite.rel.RelFieldCollation#NullDirection
The following examples show how to use
org.apache.calcite.rel.RelFieldCollation#NullDirection .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SqlDialect.java From Bats with Apache License 2.0 | 6 votes |
/** Returns whether NULL values are sorted first or last, in this dialect, * in an ORDER BY item of a given direction. */ public RelFieldCollation.NullDirection defaultNullDirection( RelFieldCollation.Direction direction) { switch (direction) { case ASCENDING: case STRICTLY_ASCENDING: return getNullCollation().last(false) ? RelFieldCollation.NullDirection.LAST : RelFieldCollation.NullDirection.FIRST; case DESCENDING: case STRICTLY_DESCENDING: return getNullCollation().last(true) ? RelFieldCollation.NullDirection.LAST : RelFieldCollation.NullDirection.FIRST; default: return RelFieldCollation.NullDirection.UNSPECIFIED; } }
Example 2
Source File: RelBuilder.java From Bats with Apache License 2.0 | 6 votes |
private static RelFieldCollation collation(RexNode node, RelFieldCollation.Direction direction, RelFieldCollation.NullDirection nullDirection, List<RexNode> extraNodes) { switch (node.getKind()) { case INPUT_REF: return new RelFieldCollation(((RexInputRef) node).getIndex(), direction, Util.first(nullDirection, direction.defaultNullDirection())); case DESCENDING: return collation(((RexCall) node).getOperands().get(0), RelFieldCollation.Direction.DESCENDING, nullDirection, extraNodes); case NULLS_FIRST: return collation(((RexCall) node).getOperands().get(0), direction, RelFieldCollation.NullDirection.FIRST, extraNodes); case NULLS_LAST: return collation(((RexCall) node).getOperands().get(0), direction, RelFieldCollation.NullDirection.LAST, extraNodes); default: final int fieldIndex = extraNodes.size(); extraNodes.add(node); return new RelFieldCollation(fieldIndex, direction, Util.first(nullDirection, direction.defaultNullDirection())); } }
Example 3
Source File: SqlDialect.java From calcite with Apache License 2.0 | 6 votes |
/** Returns whether NULL values are sorted first or last, in this dialect, * in an ORDER BY item of a given direction. */ public @Nonnull RelFieldCollation.NullDirection defaultNullDirection( RelFieldCollation.Direction direction) { switch (direction) { case ASCENDING: case STRICTLY_ASCENDING: return getNullCollation().last(false) ? RelFieldCollation.NullDirection.LAST : RelFieldCollation.NullDirection.FIRST; case DESCENDING: case STRICTLY_DESCENDING: return getNullCollation().last(true) ? RelFieldCollation.NullDirection.LAST : RelFieldCollation.NullDirection.FIRST; default: return RelFieldCollation.NullDirection.UNSPECIFIED; } }
Example 4
Source File: RelBuilder.java From calcite with Apache License 2.0 | 6 votes |
private static RelFieldCollation collation(RexNode node, RelFieldCollation.Direction direction, RelFieldCollation.NullDirection nullDirection, List<RexNode> extraNodes) { switch (node.getKind()) { case INPUT_REF: return new RelFieldCollation(((RexInputRef) node).getIndex(), direction, Util.first(nullDirection, direction.defaultNullDirection())); case DESCENDING: return collation(((RexCall) node).getOperands().get(0), RelFieldCollation.Direction.DESCENDING, nullDirection, extraNodes); case NULLS_FIRST: return collation(((RexCall) node).getOperands().get(0), direction, RelFieldCollation.NullDirection.FIRST, extraNodes); case NULLS_LAST: return collation(((RexCall) node).getOperands().get(0), direction, RelFieldCollation.NullDirection.LAST, extraNodes); default: final int fieldIndex = extraNodes.size(); extraNodes.add(node); return new RelFieldCollation(fieldIndex, direction, Util.first(nullDirection, direction.defaultNullDirection())); } }
Example 5
Source File: RelJson.java From Bats with Apache License 2.0 | 5 votes |
public RelFieldCollation toFieldCollation(Map<String, Object> map) { final Integer field = (Integer) map.get("field"); final RelFieldCollation.Direction direction = Util.enumVal(RelFieldCollation.Direction.class, (String) map.get("direction")); final RelFieldCollation.NullDirection nullDirection = Util.enumVal(RelFieldCollation.NullDirection.class, (String) map.get("nulls")); return new RelFieldCollation(field, direction, nullDirection); }
Example 6
Source File: RexFieldCollation.java From Bats with Apache License 2.0 | 5 votes |
public RelFieldCollation.NullDirection getNullDirection() { return right.contains(SqlKind.NULLS_LAST) ? RelFieldCollation.NullDirection.LAST : right.contains(SqlKind.NULLS_FIRST) ? RelFieldCollation.NullDirection.FIRST : getDirection().defaultNullDirection(); }
Example 7
Source File: RexNodeConverter.java From flink with Apache License 2.0 | 5 votes |
private RexNode createCollation(RexNode node, RelFieldCollation.Direction direction, RelFieldCollation.NullDirection nullDirection, Set<SqlKind> kinds) { switch (node.getKind()) { case DESCENDING: kinds.add(node.getKind()); return createCollation(((RexCall) node).getOperands().get(0), RelFieldCollation.Direction.DESCENDING, nullDirection, kinds); case NULLS_FIRST: kinds.add(node.getKind()); return createCollation(((RexCall) node).getOperands().get(0), direction, RelFieldCollation.NullDirection.FIRST, kinds); case NULLS_LAST: kinds.add(node.getKind()); return createCollation(((RexCall) node).getOperands().get(0), direction, RelFieldCollation.NullDirection.LAST, kinds); default: if (nullDirection == null) { // Set the null direction if not specified. // Consistent with HIVE/SPARK/MYSQL/BLINK-RUNTIME. if (FlinkPlannerImpl.defaultNullCollation() .last(direction.equals(RelFieldCollation.Direction.DESCENDING))) { kinds.add(SqlKind.NULLS_LAST); } else { kinds.add(SqlKind.NULLS_FIRST); } } return node; } }
Example 8
Source File: OverConvertRule.java From flink with Apache License 2.0 | 5 votes |
private RexNode createCollation( RexNode node, RelFieldCollation.Direction direction, RelFieldCollation.NullDirection nullDirection, Set<SqlKind> kinds) { switch (node.getKind()) { case DESCENDING: kinds.add(node.getKind()); return createCollation(((RexCall) node).getOperands().get(0), RelFieldCollation.Direction.DESCENDING, nullDirection, kinds); case NULLS_FIRST: kinds.add(node.getKind()); return createCollation(((RexCall) node).getOperands().get(0), direction, RelFieldCollation.NullDirection.FIRST, kinds); case NULLS_LAST: kinds.add(node.getKind()); return createCollation(((RexCall) node).getOperands().get(0), direction, RelFieldCollation.NullDirection.LAST, kinds); default: if (nullDirection == null) { // Set the null direction if not specified. // Consistent with HIVE/SPARK/MYSQL/BLINK-RUNTIME. if (FlinkPlannerImpl.defaultNullCollation() .last(direction.equals(RelFieldCollation.Direction.DESCENDING))) { kinds.add(SqlKind.NULLS_LAST); } else { kinds.add(SqlKind.NULLS_FIRST); } } return node; } }
Example 9
Source File: RelJson.java From calcite with Apache License 2.0 | 5 votes |
public RelFieldCollation toFieldCollation(Map<String, Object> map) { final Integer field = (Integer) map.get("field"); final RelFieldCollation.Direction direction = Util.enumVal(RelFieldCollation.Direction.class, (String) map.get("direction")); final RelFieldCollation.NullDirection nullDirection = Util.enumVal(RelFieldCollation.NullDirection.class, (String) map.get("nulls")); return new RelFieldCollation(field, direction, nullDirection); }
Example 10
Source File: RexFieldCollation.java From calcite with Apache License 2.0 | 5 votes |
public RelFieldCollation.NullDirection getNullDirection() { return right.contains(SqlKind.NULLS_LAST) ? RelFieldCollation.NullDirection.LAST : right.contains(SqlKind.NULLS_FIRST) ? RelFieldCollation.NullDirection.FIRST : getDirection().defaultNullDirection(); }
Example 11
Source File: BaseTestOperator.java From dremio-oss with Apache License 2.0 | 4 votes |
protected Order.Ordering ordering(String expression, RelFieldCollation.Direction direction, RelFieldCollation.NullDirection nullDirection) { return new Order.Ordering(direction, parseExpr(expression), nullDirection); }