PyRSA commented on code in PR #11031:
URL: https://github.com/apache/paimon/pull/11031#discussion_r4585855157


##########
paimon-python/pypaimon/execution/native/read/table_read.py:
##########
@@ -40,6 +40,54 @@
 _NATIVE_READ_FILE_SUFFIXES = tuple('.%s' % file_format for file_format in 
_NATIVE_READ_FILE_FORMATS)
 _NATIVE_BLOB_FILE_SUFFIXES = ('.blob', '.video')
 
+# merge_map_with_keytime always uses the Python aggregator for now:
+# * STRING/CHAR/VARCHAR: Rust UTF-8 ``&str`` order diverges from
+#   Java/Python UTF-16 (e.g. U+E000 vs U+10000).
+# * Every other timestamp type historically fell back already (the old
+#   Native gate only cleared STRING-family via StringArray), and there
+#   is no end-to-end-correct Native replacement without a Rust compare
+#   fix. Fall back before Native opens; do not catch mid-read.
+_MERGE_MAP_WITH_KEYTIME = "merge_map_with_keytime"
+
+
+def _field_agg_func_name(field_name, primary_keys, options_map, 
sequence_fields):
+    # Same precedence as Python ``resolve_agg_func_name`` / Java
+    # ``AggregateMergeFunction.getAggFuncName``, inlined to avoid a
+    # Native → Python execution import.
+    if field_name in sequence_fields:
+        return "last_value"
+    if field_name in primary_keys:
+        return "primary_key"
+    return (
+        options_map.get("fields.{}.aggregate-function".format(field_name))
+        or options_map.get("fields.default-aggregate-function")
+        or "last_non_null_value"
+    )
+
+
+def _native_merge_map_keytime_timestamp_supported(table) -> bool:
+    """Whether Native can run ``merge_map_with_keytime`` for this table.
+
+    Always ``False`` when any field uses ``merge_map_with_keytime`` on a
+    PK aggregation table. Non-PK / non-AGGREGATE / other aggregators are
+    unchanged and still clear this gate.
+    """
+    if not getattr(table, 'is_primary_key_table', False):
+        return True
+    options = table.options
+    if options.merge_engine() != MergeEngine.AGGREGATE:

Review Comment:
   Thanks for catching this case. Fixed in the latest commit.
   
   The Native Reader gate now also detects `merge_map_with_keytime` under the 
Partial Update merge engine, including sequence-group fields. Since the Python 
Reader does not support this Partial Update aggregation path, it now raises 
`NotImplementedError` before opening the Native Reader instead of silently 
returning an incorrect result. Added a regression test for this behavior.



-- 
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]

Reply via email to