fengruotj opened a new issue, #11435:
URL: https://github.com/apache/paimon/issues/11435

   ### Search before asking
   
   - [x] I searched in the [issues](https://github.com/apache/paimon/issues) 
and found nothing similar.
   
   
   ### Paimon version
   
   2.2-SNAPSHOT
   
   ### Compute Engine
   
   Spark SQL `3.5.10`, `local[2]`, JDK `11.0.25`.
   
   ### Minimal reproduce step
   
   1. Start Spark SQL with the Paimon SQL extensions enabled and a filesystem 
catalog named `p` pointing to a fresh warehouse. Create a single-bucket 
primary-key table. Run compaction explicitly after each write so each change 
appears in a separate changelog file.
   
   ```sql
   USE p.default;
   SET spark.sql.shuffle.partitions=1;
   SET spark.sql.files.minPartitionNum=1;
   
   CREATE TABLE events (id INT, v INT) USING paimon
   TBLPROPERTIES (
     'primary-key' = 'id',
     'bucket' = '1',
     'write-only' = 'true',
     'changelog-producer' = 'full-compaction',
     'changelog-producer.ignore-update-before' = 'true'
   );
   
   INSERT INTO events VALUES (1, 10);
   CALL p.sys.compact(table => 'default.events');
   
   INSERT INTO events VALUES (1, 20);
   CALL p.sys.compact(table => 'default.events');
   
   INSERT INTO events VALUES (1, 30);
   CALL p.sys.compact(table => 'default.events');
   ```
   
   2. Query each compaction separately. In this run the APPEND snapshots were 
1, 3 and 5, and the COMPACT snapshots were 2, 4 and 6.
   
   ```sql
   SELECT rowkind, id, v FROM paimon_incremental_query('`events$audit_log`', 1, 
2);
   -- +I  1  10
   
   SELECT rowkind, id, v FROM paimon_incremental_query('`events$audit_log`', 3, 
4);
   -- +U  1  20
   
   SELECT rowkind, id, v FROM paimon_incremental_query('`events$audit_log`', 5, 
6);
   -- +U  1  30
   ```
   
   3. Read the same changes in one query.
   
   ```sql
   SELECT rowkind, id, v
   FROM paimon_incremental_query('`events$audit_log`', 1, 6)
   ORDER BY v
   ```
   
   ### What doesn't meet your expectations?
   
   The combined query succeeds but returns only the last update. I expected all 
three audit records that can be read individually.
   
   ```text
   Expected                 Actual
   rowkind  id   v          rowkind  id   v
   -------  --  --          -------  --  --
   +I        1  10          +U        1  30
   +U        1  20
   +U        1  30
   ```
   
   ### Anything else?
   
   I traced the same three changelog files through Spark split packing. The 
input `DataSplit` had `rawConvertible=true` and `isStreaming=true`. 
`BinPackingSplits.copyDataSplit` copied the files and `rawConvertible` into a 
new split, leaving `isStreaming` at its default of `false`. For this audit 
query, that switches the reader from reading each change to merging records by 
primary key. 
[BinPackingSplits.scala](https://github.com/apache/paimon/blob/0f25b7cd8d33b62ea8848d6379c46a906c374603/paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/read/BinPackingSplits.scala#L203-L219)
 ยท 
[MergeFileSplitRead.java](https://github.com/apache/paimon/blob/0f25b7cd8d33b62ea8848d6379c46a906c374603/paimon-core/src/main/java/org/apache/paimon/operation/MergeFileSplitRead.java#L252-L267)
   
   I reran the combined query against the same files with only 
`.isStreaming(split.isStreaming)` added to the builder. It returned all three 
expected rows.
   
   ### Are you willing to submit a PR?
   
   - [ ] I'm willing to submit a PR!


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