Skip to content
This repository was archived by the owner on Aug 4, 2025. It is now read-only.

Commit 882b007

Browse files
authored
chore: remove the engine switching logic (#1)
1 parent ad72073 commit 882b007

File tree

6 files changed

+11900
-12052
lines changed

6 files changed

+11900
-12052
lines changed

README.md

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Redshift Parser
22

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.
44

55
## Overview
66

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.
88

99
## Features
1010

1111
- **Complete SQL Support**: Parses 200+ SQL statement types including DDL, DML, and advanced constructs
1212
- **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
1414
- **Comprehensive Testing**: 200+ test cases covering real-world SQL scenarios
1515
- **High Performance**: Optimized for production use with parser reuse and efficient error handling
1616

@@ -45,9 +45,6 @@ func main() {
4545
stream := antlr.NewCommonTokenStream(lexer, 0)
4646
p := parser.NewRedshiftParser(stream)
4747

48-
// Set engine to Redshift for dialect-specific parsing
49-
p.Engine = parser.EngineRedshift
50-
5148
// Parse the SQL
5249
tree := p.Root()
5350

@@ -79,24 +76,15 @@ func main() {
7976
- Regular expressions
8077
- Full-text search
8178

82-
## Engine Modes
83-
84-
The parser supports two engine modes:
79+
## Redshift-Specific Features
8580

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:
9382

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
10088

10189
## Development
10290

@@ -130,12 +118,11 @@ redshift-parser/
130118
├── RedshiftParser.g4 # ANTLR parser grammar
131119
├── build.sh # Code generation script
132120
├── 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
134122
├── keywords.go # 600+ SQL keywords
135123
├── builtin_function.go # Built-in function definitions
136124
├── examples/ # 200+ SQL test files
137125
├── parser_test.go # Main test suite
138-
├── engine_specific_test.go # Engine-specific tests
139126
└── CLAUDE.md # Development guide
140127
```
141128

@@ -153,8 +140,6 @@ go test -run TestRedshiftParser -v
153140
# Run benchmarks
154141
go test -bench=. -v
155142

156-
# Test specific engine
157-
go test -run TestRedshiftSyntax -v
158143
```
159144

160145
Test files are located in the `examples/` directory and cover:

RedshiftParser.g4

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,8 +672,7 @@ typedtableelement
672672
;
673673

674674
columnDef
675-
: { $parser.Engine!=EngineRedshift }? colid typename create_generic_options? colquallist
676-
| { $parser.Engine==EngineRedshift }? colid typename create_generic_options? rs_colattributes? colquallist
675+
: colid typename create_generic_options? rs_colattributes? colquallist
677676
;
678677

679678
rs_colattributes

RedshiftParser.interp

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

engine_specific_test.go

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)