Skip to content

Fix EXPLAIN (TYPE IO) failure when constraint contains type which cannot be cast to varchar#27433

Merged
findepi merged 3 commits intotrinodb:masterfrom
hqbhoho:fix/explain_io
Nov 27, 2025
Merged

Fix EXPLAIN (TYPE IO) failure when constraint contains type which cannot be cast to varchar#27433
findepi merged 3 commits intotrinodb:masterfrom
hqbhoho:fix/explain_io

Conversation

@hqbhoho
Copy link
Copy Markdown
Contributor

@hqbhoho hqbhoho commented Nov 25, 2025

Description

Avoid exception if constraint contain type which can't cast to varchar

Additional context and related issues

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(X) Release notes are required, with the following suggested text:

## General
* Fix `EXPLAIN (TYPE IO)` failure when query constraint contains type which cannot be cast to `varchar`. ({issue}`27433 `)

@cla-bot cla-bot bot added the cla-signed label Nov 25, 2025
@hqbhoho hqbhoho marked this pull request as draft November 25, 2025 11:29
@Praveen2112
Copy link
Copy Markdown
Member

Can we add some test case to this changes

Avoid exception if constraint contain type which can't cast to varchar
@github-actions github-actions bot added the hive Hive connector label Nov 26, 2025
@hqbhoho hqbhoho marked this pull request as ready for review November 26, 2025 10:38
@findepi findepi changed the title Avoid exception in EXPLAIN (TYPE IO) Fix EXPLAIN (TYPE IO) failure when constraint contains type which cannot be cast to varchar Nov 27, 2025
discreteValues -> formattedRanges.addAll(
discreteValues.getValues().stream()
.map(value -> valuePrinter.castToVarcharOrFail(type, value))
.map(value -> valuePrinter.castToVarchar(type, value))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

castToVarchar is misnamed, exactly because may return something else when cast would fail
calling it "toPrintable" or "toString" would be better.
Let's rename as a separate PR (before or after this one)

Copy link
Copy Markdown
Contributor Author

@hqbhoho hqbhoho Nov 27, 2025

Choose a reason for hiding this comment

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

okk, I will file a new PR to rename castToVarchar to toString and remove castToVarcharOrFail after this one merged.

@findepi findepi merged commit bd54570 into trinodb:master Nov 27, 2025
100 checks passed
@github-actions github-actions bot added this to the 479 milestone Nov 27, 2025
@chenjian2664
Copy link
Copy Markdown
Contributor

@hqbhoho The pr got merged, FYI

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

Labels

cla-signed hive Hive connector

Development

Successfully merging this pull request may close these issues.

5 participants