Skip to content

Commit 3f0df08

Browse files
lxynovebyhr
authored andcommitted
Update Snowflake Connector type mapping doc
1 parent 3e1e31c commit 3f0df08

File tree

1 file changed

+157
-24
lines changed

1 file changed

+157
-24
lines changed

docs/src/main/sphinx/connector/snowflake.md

Lines changed: 157 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,30 +49,163 @@ multiple instances of the Snowflake connector.
4949

5050
## Type mapping
5151

52-
Trino supports the following Snowflake data types:
53-
54-
| Snowflake Type | Trino Type |
55-
| -------------- | -------------- |
56-
| `boolean` | `boolean` |
57-
| `tinyint` | `bigint` |
58-
| `smallint` | `bigint` |
59-
| `byteint` | `bigint` |
60-
| `int` | `bigint` |
61-
| `integer` | `bigint` |
62-
| `bigint` | `bigint` |
63-
| `float` | `real` |
64-
| `real` | `real` |
65-
| `double` | `double` |
66-
| `decimal` | `decimal(P,S)` |
67-
| `varchar(n)` | `varchar(n)` |
68-
| `char(n)` | `varchar(n)` |
69-
| `binary(n)` | `varbinary` |
70-
| `varbinary` | `varbinary` |
71-
| `date` | `date` |
72-
| `time(n)` | `time(n)` |
73-
| `timestampntz` | `timestamp` |
74-
75-
Complete list of [Snowflake data types](https://docs.snowflake.com/en/sql-reference/intro-summary-data-types.html).
52+
Because Trino and Snowflake each support types that the other does not, this
53+
connector {ref}`modifies some types <type-mapping-overview>` when reading or
54+
writing data. Data types may not map the same way in both directions between
55+
Trino and the data source. Refer to the following sections for type mapping in
56+
each direction.
57+
58+
List of [Snowflake data types](https://docs.snowflake.com/en/sql-reference/intro-summary-data-types.html).
59+
60+
### Snowflake type to Trino type mapping
61+
62+
The connector maps Snowflake types to the corresponding Trino types following
63+
this table:
64+
65+
:::{list-table} Snowflake type to Trino type mapping
66+
:widths: 30, 30, 40
67+
:header-rows: 1
68+
69+
* - Snowflake type
70+
- Trino type
71+
- Notes
72+
* - `BOOLEAN`
73+
- `BOOLEAN`
74+
-
75+
* - `INT`, `INTEGER`, `BIGINT`, `SMALLINT`, `TINYINT`, `BYTEINT`
76+
- `DECIMAL(38,0)`
77+
- Synonymous with `NUMBER(38,0)`. See Snowflake
78+
[data types for fixed point numbers](https://docs.snowflake.com/en/sql-reference/data-types-numeric#data-types-for-fixed-point-numbers)
79+
for more information.
80+
* - `FLOAT`, `FLOAT4`, `FLOAT8`
81+
- `DOUBLE`
82+
- The names `FLOAT`, `FLOAT4`, and `FLOAT8` are for compatibility with other systems; Snowflake treats all three as
83+
64-bit floating-point numbers. See Snowflake
84+
[data types for floating point numbers](https://docs.snowflake.com/en/sql-reference/data-types-numeric#data-types-for-floating-point-numbers)
85+
for more information.
86+
* - `DOUBLE`, `DOUBLE PRECISION`, `REAL`
87+
- `DOUBLE`
88+
- Synonymous with `FLOAT`. See Snowflake
89+
[data types for floating point numbers](https://docs.snowflake.com/en/sql-reference/data-types-numeric#data-types-for-floating-point-numbers)
90+
for more information.
91+
* - `NUMBER`
92+
- `DECIMAL`
93+
- Default precision and scale are (38,0).
94+
* - `DECIMAL`, `NUMERIC`
95+
- `DECIMAL`
96+
- Synonymous with `NUMBER`. See Snowflake
97+
[data types for fixed point numbers](https://docs.snowflake.com/en/sql-reference/data-types-numeric#data-types-for-fixed-point-numbers)
98+
for more information.
99+
* - `VARCHAR`
100+
- `VARCHAR`
101+
-
102+
* - `CHAR`, `CHARACTER`
103+
- `VARCHAR`
104+
- Synonymous with `VARCHAR` except default length is `VARCHAR(1)`. See Snowflake
105+
[String & Binary Data Types](https://docs.snowflake.com/en/sql-reference/data-types-text)
106+
for more information.
107+
* - `STRING`, `TEXT`
108+
- `VARCHAR`
109+
- Synonymous with `VARCHAR`. See Snowflake
110+
[String & Binary Data Types](https://docs.snowflake.com/en/sql-reference/data-types-text)
111+
for more information.
112+
* - `BINARY`
113+
- `VARBINARY`
114+
-
115+
* - `VARBINARY`
116+
- `VARBINARY`
117+
- Synonymous with `BINARY`. See Snowflake
118+
[String & Binary Data Types](https://docs.snowflake.com/en/sql-reference/data-types-text)
119+
for more information.
120+
* - `DATE`
121+
- `DATE`
122+
-
123+
* - `TIME`
124+
- `TIME`
125+
-
126+
* - `TIMESTAMP_NTZ`
127+
- `TIMESTAMP`
128+
- TIMESTAMP with no time zone; time zone, if provided, is not stored. See Snowflake
129+
[Date & Time Data Types](https://docs.snowflake.com/en/sql-reference/data-types-datetime)
130+
for more information.
131+
* - `DATETIME`
132+
- `TIMESTAMP`
133+
- Alias for `TIMESTAMP_NTZ`. See Snowflake
134+
[Date & Time Data Types](https://docs.snowflake.com/en/sql-reference/data-types-datetime)
135+
for more information.
136+
* - `TIMESTAMP`
137+
- `TIMESTAMP`
138+
- Alias for one of the `TIMESTAMP` variations (`TIMESTAMP_NTZ` by default). This connector always sets `TIMESTAMP_NTZ` as the variant.
139+
* - `TIMESTAMP_TZ`
140+
- `TIMESTAMP WITH TIME ZONE`
141+
- TIMESTAMP with time zone.
142+
:::
143+
144+
No other types are supported.
145+
146+
### Trino type to Snowflake type mapping
147+
148+
The connector maps Trino types to the corresponding Snowflake types following
149+
this table:
150+
151+
:::{list-table} Trino type to Snowflake type mapping
152+
:widths: 30, 30, 40
153+
:header-rows: 1
154+
155+
* - Trino type
156+
- Snowflake type
157+
- Notes
158+
* - `BOOLEAN`
159+
- `BOOLEAN`
160+
-
161+
* - `TINYINT`
162+
- `NUMBER(3, 0)`
163+
-
164+
* - `SMALLINT`
165+
- `NUMBER(5, 0)`
166+
-
167+
* - `INTEGER`
168+
- `NUMBER(10, 0)`
169+
-
170+
* - `BIGINT`
171+
- `NUMBER(19, 0)`
172+
-
173+
* - `REAL`
174+
- `DOUBLE`
175+
-
176+
* - `DOUBLE`
177+
- `DOUBLE`
178+
-
179+
* - `DECIMAL`
180+
- `NUMBER`
181+
-
182+
* - `VARCHAR`
183+
- `VARCHAR`
184+
-
185+
* - `CHAR`
186+
- `VARCHAR`
187+
-
188+
* - `VARBINARY`
189+
- `BINARY`
190+
-
191+
* - `VARBINARY`
192+
- `VARBINARY`
193+
-
194+
* - `DATE`
195+
- `DATE`
196+
-
197+
* - `TIME`
198+
- `TIME`
199+
-
200+
* - `TIMESTAMP`
201+
- `TIMESTAMP_NTZ`
202+
-
203+
* - `TIMESTAMP WITH TIME ZONE`
204+
- `TIMESTAMP_TZ`
205+
-
206+
:::
207+
208+
No other types are supported.
76209

77210
```{include} jdbc-type-mapping.fragment
78211
```

0 commit comments

Comments
 (0)