JingsongLi commented on code in PR #6193:
URL: https://github.com/apache/paimon/pull/6193#discussion_r2335677802
##########
paimon-core/src/main/java/org/apache/paimon/utils/FormatReaderMapping.java:
##########
@@ -259,6 +278,53 @@ private TopN evolutionTopN(TableSchema tableSchema,
TableSchema dataSchema) {
return pushTopN;
}
+ @VisibleForTesting
+ static Optional<RichLimit> tryConvertTopNToLimit(
+ TopN pushTopN,
+ RichLimit pushLimit,
+ TableSchema schema,
+ boolean deletionVectorsEnabled) {
+ // only for primary key table in deletion-vector mode.
+ if (pushTopN == null
+ || pushLimit != null
+ || !deletionVectorsEnabled
+ || schema.primaryKeys().isEmpty()) {
+ return Optional.empty();
+ }
+
+ // The follow rules can convert TopN to limit.
+ // 1. The preceding sort keys must matches with the primary keys
in order,
+ // and the sort direction must be the same.
+ // 2. If non-primary key including, all the primary-key must
matches in order first.
+ List<DataField> fields = schema.primaryKeysFields();
+ List<SortValue> orders = pushTopN.orders();
+ if (isNullOrEmpty(orders)) {
+ return Optional.empty();
+ }
+
+ SortDirection firstDirection = null;
+ for (int i = 0; i < fields.size(); i++) {
Review Comment:
I don't get this loop, just check first field is OK?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]