Skip to content

Conversation

@toriwei
Copy link
Collaborator

@toriwei toriwei commented Nov 5, 2025

BigQuery UPPER() supports VARCHAR -> VARCHAR AND BYTES -> BYTES
DuckDB upper() supports VARCHAR -> VARCHAR

To improve transpilation from BigQuery, this PR allows DuckDB to handle byte input by casting it to varchar and casting the upper expression to blob. Created helper method to handle casting logic, as this mirrors the work done for LOWER transpilation #6218

BigQuery:

SELECT 
  UPPER(CAST('hello' as BYTES)) as upper_byte, 
  TYPEOF(CAST('hello' as BYTES)) as type_upper_byte, 
  UPPER('hello') AS upper_str, 
  TYPEOF(UPPER('hello')) as type_upper_str;"

+------------+-----------------+-----------+----------------+
| upper_byte | type_upper_byte | upper_str | type_upper_str |
+------------+-----------------+-----------+----------------+
|   SEVMTE8= | BYTES           | HELLO     | STRING         |
+------------+-----------------+-----------+----------------+

DuckDB:

D SELECT UPPER(CAST('hello' as BLOB)) as upper_byte, TYPEOF(CAST('hello' as BLOB)) as type_upper_byte;
Binder Error:
No function matches the given name and argument types 'upper(BLOB)'. You might need to add explicit type casts.
        Candidate functions:
        upper(VARCHAR) -> VARCHAR

D SELECT UPPER('hello') AS upper_str;
┌───────────┐
│ upper_str │
│  varchar  │
├───────────┤
│ HELLO     │
└───────────┘

@toriwei toriwei requested a review from georgesittas November 5, 2025 00:11
Copy link
Collaborator

@VaggelisD VaggelisD left a comment

Choose a reason for hiding this comment

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

Nice abstraction @toriwei! Left a couple comments:

@VaggelisD
Copy link
Collaborator

Resolving the comments because of similar discussions in the LOWER(...) PR with @georgesittas

Copy link
Collaborator

@georgesittas georgesittas left a comment

Choose a reason for hiding this comment

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

Gonna clean this up

@georgesittas georgesittas merged commit 71d93b1 into main Nov 5, 2025
7 checks passed
@georgesittas georgesittas deleted the tori/transpile-upper branch November 5, 2025 10:37
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.

4 participants