You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 4, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+11-26Lines changed: 11 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,16 @@
1
1
# Redshift Parser
2
2
3
-
A comprehensive SQL parser for Amazon Redshift built with ANTLR 4, supporting both PostgreSQL and Redshift-specific syntax.
3
+
A comprehensive SQL parser for Amazon Redshift built with ANTLR 4, optimized for Redshift-specific syntax.
4
4
5
5
## Overview
6
6
7
-
This project is a Go-based SQL parser specifically designed for Amazon Redshift. It originated as a fork of the PostgreSQL parser but has been restructured to accommodate Redshift's unique syntax requirements and incompatibilities with standard PostgreSQL.
7
+
This project is a Go-based SQL parser specifically designed for Amazon Redshift. It originated as a fork of the PostgreSQL parser but has been restructured to focus exclusively on Redshift's unique syntax requirements.
8
8
9
9
## Features
10
10
11
11
-**Complete SQL Support**: Parses 200+ SQL statement types including DDL, DML, and advanced constructs
12
12
-**Redshift-Specific Syntax**: Full support for Redshift extensions like `IDENTITY` columns, `DISTKEY`, `SORTKEY`, and more
13
-
-**Engine-Aware Parsing**: Dual-mode parser that can handle both PostgreSQL and Redshift syntax
13
+
-**Redshift-Optimized**: Parser optimized exclusively for Redshift syntax and features
14
14
-**Comprehensive Testing**: 200+ test cases covering real-world SQL scenarios
15
15
-**High Performance**: Optimized for production use with parser reuse and efficient error handling
16
16
@@ -45,9 +45,6 @@ func main() {
45
45
stream:= antlr.NewCommonTokenStream(lexer, 0)
46
46
p:= parser.NewRedshiftParser(stream)
47
47
48
-
// Set engine to Redshift for dialect-specific parsing
49
-
p.Engine = parser.EngineRedshift
50
-
51
48
// Parse the SQL
52
49
tree:= p.Root()
53
50
@@ -79,24 +76,15 @@ func main() {
79
76
- Regular expressions
80
77
- Full-text search
81
78
82
-
## Engine Modes
83
-
84
-
The parser supports two engine modes:
79
+
## Redshift-Specific Features
85
80
86
-
### Redshift Mode
87
-
```go
88
-
p.Engine = parser.EngineRedshift
89
-
```
90
-
- Supports Redshift-specific syntax extensions
91
-
- Handles `IDENTITY` columns, distribution keys, sort keys
92
-
- Supports Redshift built-in functions and data types
81
+
The parser is optimized for Redshift's unique SQL extensions:
93
82
94
-
### PostgreSQL Mode
95
-
```go
96
-
p.Engine = parser.EnginePostgreSQL
97
-
```
98
-
- Standard PostgreSQL syntax compliance
99
-
- Useful for compatibility testing and migration scenarios
83
+
-**IDENTITY columns**: `CREATE TABLE t (id INT IDENTITY(1,1))`
84
+
-**Distribution keys**: `DISTKEY(column_name)`
85
+
-**Sort keys**: `SORTKEY(column_name)`
86
+
-**Redshift built-in functions**: Comprehensive support for Redshift-specific functions
87
+
-**Data types**: All Redshift-supported data types including extensions
100
88
101
89
## Development
102
90
@@ -130,12 +118,11 @@ redshift-parser/
130
118
├── RedshiftParser.g4 # ANTLR parser grammar
131
119
├── build.sh # Code generation script
132
120
├── redshift_lexer_base.go # Base lexer implementation
133
-
├── redshift_parser_base.go # Base parser with engine support
121
+
├── redshift_parser_base.go # Base parser implementation
134
122
├── keywords.go # 600+ SQL keywords
135
123
├── builtin_function.go # Built-in function definitions
0 commit comments