Skip to content

Commit 0f244f3

Browse files
committed
Enhance documentation on PostgreSQL identifier handling in datasets and SELECT syntax
1 parent acbe8ab commit 0f244f3

4 files changed

Lines changed: 70 additions & 2 deletions

File tree

website/docs/reference/spicepod/datasets.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,28 @@ datasets:
130130

131131
The name of the dataset. Used to reference the dataset in the pod manifest, as well as in external data sources. The name cannot be a [reserved keyword](./keywords).
132132

133+
Spice follows PostgreSQL SQL syntax conventions, which normalize unquoted identifiers to lowercase. A dataset named `LINEITEM` is accessible in queries as `lineitem`.
134+
135+
To preserve uppercase or mixed-case names, wrap the name in double quotes. In YAML, this requires an extra layer of quoting:
136+
137+
```yaml
138+
datasets:
139+
- from: snowflake:SNOWFLAKE_SAMPLE_DATA.TPCH_SF100.LINEITEM
140+
name: '"LINEITEM"'
141+
params:
142+
snowflake_account: JYFGIWYEFBW
143+
snowflake_warehouse: snowflake_wh
144+
snowflake_password: ${secrets:SNOWFLAKE_PASSWORD}
145+
snowflake_username: ${secrets:SNOWFLAKE_USERNAME}
146+
```
147+
148+
```sql
149+
-- Query using the preserved uppercase name
150+
SELECT * FROM "LINEITEM";
151+
```
152+
153+
Without the double quotes, the same dataset would be queryable only as `lineitem`.
154+
133155
## `description`
134156

135157
The description of the dataset. Used as part of the [Semantic Data Model](../../features/semantic-model).

website/docs/reference/sql/select.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,19 @@ Spice is built on [Apache DataFusion](https://datafusion.apache.org/) and uses t
1313
## SELECT syntax
1414

1515
The queries in Spice scan data from tables and return 0 or more rows.
16-
Please be aware that column names in queries are made lower-case, but not on the inferred schema. Accordingly, if you want to query against a capitalized field, make sure to use double quotes.
16+
17+
Spice follows PostgreSQL conventions for identifier handling: unquoted identifiers (table and column names) are normalized to lowercase. To reference a table or column with uppercase or mixed-case characters, wrap the identifier in double quotes.
18+
19+
```sql
20+
-- These are equivalent (both reference the lowercase table name)
21+
SELECT * FROM lineitem;
22+
SELECT * FROM LINEITEM;
23+
24+
-- Double quotes preserve the exact casing
25+
SELECT * FROM "LINEITEM";
26+
```
27+
28+
See [dataset `name` configuration](../spicepod/datasets#name) for how to set a case-sensitive dataset name in the Spicepod manifest.
1729

1830
Spice supports the following syntax for queries:
1931

website/versioned_docs/version-1.11.x/reference/spicepod/datasets.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,28 @@ datasets:
130130

131131
The name of the dataset. Used to reference the dataset in the pod manifest, as well as in external data sources. The name cannot be a [reserved keyword](./keywords).
132132

133+
Spice follows PostgreSQL SQL syntax conventions, which normalize unquoted identifiers to lowercase. A dataset named `LINEITEM` is accessible in queries as `lineitem`.
134+
135+
To preserve uppercase or mixed-case names, wrap the name in double quotes. In YAML, this requires an extra layer of quoting:
136+
137+
```yaml
138+
datasets:
139+
- from: snowflake:SNOWFLAKE_SAMPLE_DATA.TPCH_SF100.LINEITEM
140+
name: '"LINEITEM"'
141+
params:
142+
snowflake_account: JYFGIWYEFBW
143+
snowflake_warehouse: snowflake_wh
144+
snowflake_password: ${secrets:SNOWFLAKE_PASSWORD}
145+
snowflake_username: ${secrets:SNOWFLAKE_USERNAME}
146+
```
147+
148+
```sql
149+
-- Query using the preserved uppercase name
150+
SELECT * FROM "LINEITEM";
151+
```
152+
153+
Without the double quotes, the same dataset would be queryable only as `lineitem`.
154+
133155
## `description`
134156

135157
The description of the dataset. Used as part of the [Semantic Data Model](../../features/semantic-model).

website/versioned_docs/version-1.11.x/reference/sql/select.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,19 @@ Spice is built on [Apache DataFusion](https://datafusion.apache.org/) and uses t
1313
## SELECT syntax
1414

1515
The queries in Spice scan data from tables and return 0 or more rows.
16-
Please be aware that column names in queries are made lower-case, but not on the inferred schema. Accordingly, if you want to query against a capitalized field, make sure to use double quotes.
16+
17+
Spice follows PostgreSQL conventions for identifier handling: unquoted identifiers (table and column names) are normalized to lowercase. To reference a table or column with uppercase or mixed-case characters, wrap the identifier in double quotes.
18+
19+
```sql
20+
-- These are equivalent (both reference the lowercase table name)
21+
SELECT * FROM lineitem;
22+
SELECT * FROM LINEITEM;
23+
24+
-- Double quotes preserve the exact casing
25+
SELECT * FROM "LINEITEM";
26+
```
27+
28+
See [dataset `name` configuration](../spicepod/datasets#name) for how to set a case-sensitive dataset name in the Spicepod manifest.
1729

1830
Spice supports the following syntax for queries:
1931

0 commit comments

Comments
 (0)