Skip to content

Fix the NULL result of field() key expressions with fan-type Concatenate#4130

Open
RobertBrunel wants to merge 1 commit intoFoundationDB:mainfrom
RobertBrunel:field-Concatenate
Open

Fix the NULL result of field() key expressions with fan-type Concatenate#4130
RobertBrunel wants to merge 1 commit intoFoundationDB:mainfrom
RobertBrunel:field-Concatenate

Conversation

@RobertBrunel
Copy link
Copy Markdown
Contributor

@RobertBrunel RobertBrunel commented May 5, 2026

This change makes FieldKeyExpression#getNullResult() propagate the null stand-in for fan-type Concatenate instead of returning an empty list. This aligns Concatenate with the None branch, as the null stand-in is more appropriate behavior for this case. The empty list is only correct when the stand-in is NOT_NULL, since the empty list is the proto default for a repeated field.

This change is desirable for alignment with SQL semantics; see the example scenario described under Issue #4129. However, note that it is a breaking change that affects persisted index entries. Deployed indexes will have persisted a scalar(emptyList) in the cases described here and should be rebuilt so they instead persist the scalar(NULL) going forward. We expect the impact to be limited, as Concatenate is not commonly used, and FieldKeyExpression#getNullResult() is reached only when the input message passed to evaluateMessage() is null. This, in particular, happens when a nest() expression descends into an absent parent. In other words, the Concatenate field has to sit inside a nest() expression under an optional parent and that parent submessage is absent.

Testing:

  • Update affected unit tests in KeyExpressionTest.
  • No existing .yamsql tests are affected.

Resolves #4129.

…tenate`

This change makes `FieldKeyExpression#getNullResult()` propagate the null stand-in for fan-type `Concatenate` instead of returning an empty list. This aligns `Concatenate` with the `None` branch, as the null stand-in is more appropriate behavior for this case. The empty list is only correct when the stand-in is NOT_NULL, since that matches the proto default for a repeated field.

This change is desirable for alignment with SQL semantics; see the example scenario described under Issue FoundationDB#4129. However, note that it is a **breaking change** that affects persisted index entries. Deployed indexes will have persisted a `scalar(emptyList)` in the cases described here and should be rebuilt so they instead persist the `scalar(NULL)` going forward. We expect the impact to be limited, as `Concatenate` is not commonly used, and `FieldKeyExpression#getNullResult()` is reached only when the input message passed to `evaluateMessage()` is null. This, in particular, happens when a `nest()` expression descends into an absent parent. In other words, the Concatenate field has to sit inside a `nest()` expression under an optional parent and that parent submessage is absent.

Testing:
* Update affected unit tests in `KeyExpressionTest`.
* No existing .yamsql tests are affected.

Resolves FoundationDB#4129.
@RobertBrunel RobertBrunel self-assigned this May 5, 2026
@RobertBrunel RobertBrunel added bug fix Change that fixes a bug breaking change Changes that are not backwards compatible labels May 5, 2026
@RobertBrunel RobertBrunel changed the title Fix the NULL result of field() key expressions with fan-type `Conca… Fix the NULL result of field() key expressions with fan-type Concatenate May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Changes that are not backwards compatible bug fix Change that fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

field() key expressions with fan-type Concatenate propagate an “absent” repeated field as an empty list instead of the null standin

1 participant