BigQuery · String function
BigQuery UPPER
UPPER(value) converts a string to uppercase using Unicode case rules: UPPER('de-be') returns DE-BE. Use it to normalize codes such as country, currency and SKU values before comparing, grouping or joining.
UPPER maps every alphabetic character of a STRING to its uppercase form, following the Unicode Character Database without language-specific rules. Some characters expand when uppercased: the German ß becomes SS, so the result can be longer than the input. For BYTES, only ASCII letters change.
Typical uses are normalizing ISO codes (UPPER(country_code)), making join keys consistent, and case-insensitive comparisons. LOWER works the same way in the other direction; pick one convention and apply it on both sides of a comparison.
UPPER returns NULL for NULL. To capitalize only the first letter of each word, use INITCAP.
Syntax
UPPER(value)Arguments and return value
| Argument | Description |
|---|---|
value | The STRING or BYTES value to convert. |
Returns: STRING or BYTES, the same type as value.
Examples
Uppercase codes and accented text
ß uppercases to two characters, so the 6-letter word becomes 7.
SELECT
UPPER('eur') AS currency,
UPPER('café') AS accented,
UPPER('straße') AS expands,
LENGTH(UPPER('straße')) AS length_after_upper;| currency | accented | expands | length_after_upper |
|---|---|---|---|
| EUR | CAFÉ | STRASSE | 7 |
Join on normalized country codes
WITH orders AS (
SELECT 1 AS order_id, 'de' AS country UNION ALL
SELECT 2, 'DE' UNION ALL
SELECT 3, ' fr'
),
countries AS (
SELECT 'DE' AS code, 'Germany' AS country_name UNION ALL
SELECT 'FR', 'France'
)
SELECT o.order_id, c.country_name
FROM orders AS o
JOIN countries AS c ON UPPER(TRIM(o.country)) = c.code
ORDER BY o.order_id;| order_id | country_name |
|---|---|
| 1 | Germany |
| 2 | Germany |
| 3 | France |
Common mistakes
- Assuming UPPER keeps the string length. Characters such as
ßexpand, so fixed-width logic based on LENGTH can break. - Normalizing only one side of a comparison.
UPPER(country) = 'de'never matches; uppercase both sides or compare to an uppercase literal. - Wrapping a clustered filter column in UPPER. The function prevents block pruning on that column; store normalized values instead.
- Looking for UCASE. BigQuery only has UPPER.
Cost and performance
- On a table with a search index that uses the default LOG_ANALYZER,
UPPER(column) = 'LITERAL'can still use the index. On a clustered column without an index, the function in the filter stops block pruning.
FAQ
How do I convert a string to uppercase in BigQuery?
Use UPPER(value). It handles accented and non-Latin letters for STRING values.
How do I capitalize only the first letter in BigQuery?
For every word, use INITCAP(value). For only the first character of the string, use CONCAT(UPPER(LEFT(value, 1)), SUBSTR(value, 2)).
Related
More string functions
All BigQuery string functions · All functions · BigQuery error messages
