private static List<RelCollation> deduceMonotonicity( Prepare.PreparingTable table) { final List<RelCollation> collationList = new ArrayList<>(); // Deduce which fields the table is sorted on. int i = -1; for (RelDataTypeField field : table.getRowType().getFieldList()) { ++i; final SqlMonotonicity monotonicity = table.getMonotonicity(field.getName()); if (monotonicity != SqlMonotonicity.NOT_MONOTONIC) { final RelFieldCollation.Direction direction = monotonicity.isDecreasing() ? RelFieldCollation.Direction.DESCENDING : RelFieldCollation.Direction.ASCENDING; collationList.add( RelCollations.of( new RelFieldCollation(i, direction))); } } return collationList; }
private static List<RelCollation> deduceMonotonicity( Prepare.PreparingTable table) { final List<RelCollation> collationList = new ArrayList<>(); // Deduce which fields the table is sorted on. int i = -1; for (RelDataTypeField field : table.getRowType().getFieldList()) { ++i; final SqlMonotonicity monotonicity = table.getMonotonicity(field.getName()); if (monotonicity != SqlMonotonicity.NOT_MONOTONIC) { final RelFieldCollation.Direction direction = monotonicity.isDecreasing() ? RelFieldCollation.Direction.DESCENDING : RelFieldCollation.Direction.ASCENDING; collationList.add( RelCollations.of( new RelFieldCollation(i, direction))); } } return collationList; }
@Override public Prepare.PreparingTable getTable(List<String> names) { Prepare.PreparingTable originRelOptTable = super.getTable(names); if (originRelOptTable == null) { return null; } else { // Wrap FlinkTable as FlinkRelOptTable to use in query optimization. FlinkTable table = originRelOptTable.unwrap(FlinkTable.class); if (table != null) { return FlinkRelOptTable.create( originRelOptTable.getRelOptSchema(), originRelOptTable.getRowType(), originRelOptTable.getQualifiedName(), table); } else { return originRelOptTable; } } } }