Skip to main content

Data type case

dataTypeCase sets the case of data type names: int, varchar, boolean, numeric, a multi-word type such as timestamp with time zone, a nested type such as array<struct<x int64>>, and the type word of a typed literal such as date '2020-01-01'. It reaches every place the grammar reads a type: a column definition, a cast target, a :: cast.

Default: like_keyword. A type name is cased exactly as keywordCase cases keywords, so one setting gives CAST(x AS INT), and with keywordCase at its own default of preserve type names keep the case you wrote. Set upper, lower or preserve to case them on their own. The usual reason is a house style that writes keywords one way and types another, so that id int reads as a column and its type rather than as two more keywords.

Upper-case keywords, types on their own​

create table t (id int, name varchar(100), ts timestamp with time zone)
CREATE TABLE t(id INT, name VARCHAR(100), ts TIMESTAMP WITH TIME ZONE)
create table t (id int, name varchar(100), ts timestamp with time zone)
CREATE TABLE t(id int, name varchar(100), ts timestamp with time zone)

A multi-word type moves as one name: timestamp with time zone is one type, not a type and three keywords. Precision and scale are numbers and are never touched, so numeric(10, 2) stays numeric(10, 2) under every setting.

Where it is ignored. ClickHouse compares a type name as written: CAST(1 AS uint8) fails with Unknown data type family: uint8 where UInt8 works. There, type names are reproduced as you wrote them whatever this is set to.

Where the case of a type changes a result. On seven engines a select item with no alias is named after its own text, so re-casing a word inside one renames a column of the result. The list and the reasoning are on Keyword casing; the hazard belongs to the unaliased item, not to types in particular.