Skip to content

Fix text index direct read optimization with Nullable function arguments - #95078

Merged
alexey-milovidov merged 7 commits into
masterfrom
fix-text-index-nullable-direct-read
Jan 26, 2026
Merged

alexey-milovidov merged 7 commits into
masterfrom
fix-text-index-nullable-direct-read

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jan 25, 2026 •

Copy link
Copy Markdown
Member

The text index direct read optimization replaces text-matching functions like hasAnyTokens(val, toNullable('FOO')) with virtual columns. However, when the original function returns Nullable(UInt8) (due to nullable arguments), the virtual column was always created as UInt8, causing a type mismatch error: "Unexpected return type from not. Expected Nullable(UInt8). Got UInt8."

The fix wraps the replacement node with toNullable when the original function returns a nullable type but the replacement doesn't.

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

See #88550 (comment)

Version info

  • Merged into: 26.1.1.872

The text index direct read optimization replaces text-matching functions
like `hasAnyTokens(val, toNullable('FOO'))` with virtual columns. However,
when the original function returns `Nullable(UInt8)` (due to nullable
arguments), the virtual column was always created as `UInt8`, causing a
type mismatch error: "Unexpected return type from not. Expected
Nullable(UInt8). Got UInt8."

The fix wraps the replacement node with `toNullable` when the original
function returns a nullable type but the replacement doesn't.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jan 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b6c7698]

Summary: ✅

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jan 25, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

All fuzzer failures are pre-existing issues, not introduced by the PR. Here's the breakdown:

  1. AST fuzzer (arm_asan) - "Unexpected return type from concat"

Logical error: 'Unexpected return type from concat. Expected Nullable(String). Got String.
Query: SELECT concat(t1.id, '_1') ... FROM t1 LEFT JOIN t2 ... LEFT JOIN t3... with join_use_nulls = true

Pre-existing: This exact error (STID: 1611-343c) has appeared on master on Jan 25, Jan 8, Dec 26, Dec 22, and other dates. It's the same class of error your PR fixes (nullable type mismatch), but in a different code path (JOINs with join_use_nulls).

  1. AST fuzzer (amd_debug) - "Block structure mismatch"

Block structure mismatch in Pipe stream: different types (LowCardinality vs non-LowCardinality in Tuples)
Pre-existing: Happens almost daily on master. Different issue - LowCardinality type handling.

  1. BuzzHouse (amd_debug) - "Inconsistent AST formatting"

Pre-existing: Known issue #93861. 20-70+ failures per day across master and PRs.

  1. BuzzHouse (amd_ubsan) - "Node with duplicate alias does not exist in alias table"

Pre-existing: Appeared on master on Jan 25, Jan 19, Jan 16, Jan 15, etc. CTE/alias resolution bug.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jan 26, 2026
@alexey-milovidov alexey-milovidov self-assigned this Jan 26, 2026
Merged via the queue into master with commit bc22721 Jan 26, 2026
130 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-text-index-nullable-direct-read branch January 26, 2026 04:45
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants