Sitemap

Member-only story

Collation Modifiers in Databricks

Make case-insensitive or accent-insensitive queries easier and improve performance.

3 min readMay 17, 2025

--

What Is Collation?

A collation defines how strings are compared and sorted. You can set it when creating a table (e.g., CREATE TABLE) or use it in WHERE or ORDER BY clauses (e.g., ORDER BY mycol COLLATE “UNICODE_CI”).

Press enter or click to view image in full size

If you are not yet a member of Medium, you can access for free via a friend’s link.

-- Specify during creation of table

CREATE TABLE my_table (
id INT,
name STRING COLLATE "UNICODE_CI_AI"
);

-- You can also specify collation on the fly

SELECT name
FROM my_table
WHERE name COLLATE "UNICODE_CI" = 'john';

Key Modifiers:

CS: Case-Sensitive (default). ‘A’ ≠ ‘a’
CI: Case-Insensitive. ‘A’ = ‘a’
AS: Accent-Sensitive (default). ‘e’ ≠ ‘é’
AI: Accent-Insensitive. ‘e’ = ‘é’
RTRIM: Ignores trailing spaces. ‘Hello’ = ‘Hello ‘

You can combine modifiers (e.g., CI_AI_RTRIM).

WHERE Clause Examples:

Case-Insensitive Match

--

--

Hubert Dudek
Hubert Dudek

Written by Hubert Dudek

Databricks MVP | Advisor to Databricks Product Board | Content creator at SunnyData | creator of Databricks Community Articles publication