Skip to content

fix: preserve nulls in dictionary scalar regex - #22

Merged
discord9 merged 1 commit into
GreptimeTeam:greptimedb-53.1.0-function-signature-exec-errorfrom
discord9:fix/dictionary-regex-null
Jul 29, 2026
Merged

fix: preserve nulls in dictionary scalar regex#22
discord9 merged 1 commit into
GreptimeTeam:greptimedb-53.1.0-function-signature-exec-errorfrom
discord9:fix/dictionary-regex-null

Conversation

@discord9

Copy link
Copy Markdown

Which issue does this PR close?

  • N/A.

Rationale for this change

Dictionary-array/scalar regex evaluation first evaluates each dictionary value, then gathers those Boolean results by key. The existing BooleanArray::take_iter gather reads values without preserving the evaluated array validity, so a non-null key that references a null dictionary value becomes valid false. Negated regex operators can then incorrectly turn that logical null into true.

What changes are included in this PR?

  • Gather evaluated dictionary regex results with Arrow take, preserving nulls from both dictionary keys and dictionary values.
  • Add regression coverage for null keys, keys referencing null values, and ordinary values across ~, ~*, !~, and !~*.
  • Compare direct Dictionary results with cast-to-Utf8 results to enforce equivalent values and validity.

Are these changes tested?

Yes.

cargo test -p datafusion-physical-expr regex_scalar_with_dictionary_nulls

Result: 1 passed; 1504 filtered out. rustfmt --check and git diff --check also pass.

Are there any user-facing changes?

No API changes. This fixes SQL null propagation for Dictionary scalar regex evaluation.

Signed-off-by: discord9 <discord9@163.com>

@fengjiachun fengjiachun left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Arrow take correctly preserves null validity from both dictionary keys and values, and the regression test covers all four regex operators.

@discord9
discord9 merged commit a0af1f0 into GreptimeTeam:greptimedb-53.1.0-function-signature-exec-error Jul 29, 2026
discord9 added a commit that referenced this pull request Aug 3, 2026
Ports GreptimeTeam/datafusion PR #22
(commit aa6f9fa) onto the 54.1 thin
fork.

regex_match_dyn_scalar re-materialized the evaluated dictionary values
with take_iter, which discarded the validity of the evaluated values
array. Use arrow::compute::take so NULLs from both the dictionary keys
and the evaluated values are preserved, matching plain utf8 regex
evaluation.

Signed-off-by: discord9 <discord9@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants