apache / apache/datafusion-sqlparser-rs

Missing Redshift constructs

Open
#2,408 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
3.5k
Forks
772
Avg merge
4d 9h
Merged PRs (30d)
17

Description

`RedshiftSqlDialect` on version 0.62.0 fails to parse a few core Redshift statements that the real engine accepts (tested on Redshift 1.0.347559):

```sql
-- 1. APPROXIMATE COUNT(DISTINCT)
SELECT APPROXIMATE COUNT(DISTINCT id) FROM t;
-- Expected: end of statement, found: (

-- 2. Column-level ENCODE in CREATE TABLE
CREATE TABLE t (id INT ENCODE az64, name VARCHAR(20) ENCODE lzo);
-- Expected: ',' or ')' after column definition, found: ENCODE

-- 3. CREATE EXTERNAL SCHEMA (Spectrum)
CREATE EXTERNAL SCHEMA s FROM DATA CATALOG DATABASE 'db' IAM_ROLE 'arn:...';
-- Expected: TABLE, found: SCHEMA
```

Each is documented, common Redshift syntax:
- `APPROXIMATE COUNT(DISTINCT ...)`: HyperLogLog cardinality [(docs)](https://docs.aws.amazon.com/redshift/latest/dg/r_COUNT.html)
- column-level compression `ENCODE ` in `CREATE TABLE` [(docs)](https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html)
- `CREATE EXTERNAL SCHEMA ... FROM DATA CATALOG`: Redshift Spectrum [(docs)](https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_EXTERNAL_SCHEMA.html)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at RedshiftSqlDialect and trace the parser paths for the three SQL examples; inspect nearby dialect tests if present. Done means all three statements parse successfully: APPROXIMATE COUNT(DISTINCT), column-level ENCODE, and CREATE EXTERNAL SCHEMA.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
compilers, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.