How to order strings in BigQuery to have lowercased characters ordered before uppercased characters?
0
votes
1
answer
62
views
I'm updating a reporting tool implementation so that it queries BigQuery instead of PostgreSQL. The PostgreSQL data is ingested in BigQuery. One requirement is for the report results to stay exactly the same after this update, i.e., a report query should output the exact same results when run on BigQuery than on PostgreSQL.
In particular, I need BigQuery to order strings the same way as my PostgreSQL server currently does. It's not an option to change how my PostgreSQL server orders strings.
For example, with this table:
|name|id|
|---------|--|
|activity |1 |
|Activity |2 |
|activity |3 |
|foo |4 |
and the query
SELECT name FROM table ORDER BY name, id
my PostgreSQL returns
> activity, activity, Activity, foo
while BigQuery returns
> Activity, activity, activity, foo
I've tried
SELECT name FROM table ORDER BY NORMALIZE_AND_CASEFOLD(name), id
but BigQuery returns
> activity, Activity, activity, foo
Asked by Florent2
(349 rep)
Oct 20, 2022, 12:22 PM
Last activity: Oct 26, 2022, 07:49 AM
Last activity: Oct 26, 2022, 07:49 AM