Skip to content

[Bug] Partial-update product counts a retracted value twice when a merge starts with a retraction #11465

Backlog

Description

@houlinchn

Search before asking

  • I searched in the issues and found nothing similar.

Paimon version

master (2.2-SNAPSHOT)

Compute Engine

Java API (engine-independent; the issue is in PartialUpdateMergeFunction).

Minimal reproduce step

A primary-key partial-update table with a sequence group and a nullable product aggregate:

'merge-engine' = 'partial-update',
'fields.seq.sequence-group' = 'amount',
'fields.amount.aggregate-function' = 'product'
  1. Commit +I(amount = 5, seq = 1).
  2. Commit -U(amount = 5, seq = 2), +U(amount = 5, seq = 3).

What doesn't meet your expectations?

The table reads amount = 25; it should read 5. The result is the same with changelog-producer = none, input and lookup.

In the second commit the merge starts with a retraction. The nullable accumulator is null, and FieldProductAgg.retract(null, 5) returns null, so the retraction is dropped. The +U(5) is then multiplied into the committed 5.

Anything else?

#11274 fixes the same problem for sum. It starts the accumulator empty and, when a merge only sees retractions, writes the retracted amount in the DELETE record so the next merge retracts it again. product can't follow the same approach directly: the retraction-only state is 1 / x, which truncates to 0 for integer types and can't be stored in the field type. A fix probably needs a different representation for retraction-only results, or a documented limitation for product with retractions.

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions