Goal: replace Bytebase's ANTLR-backed Redshift parser with a hand-written Omni Redshift dialect while preserving the runtime surfaces Bytebase already enables: SQL review, syntax diagnostics, SQL editor validation, masking query span, autocomplete, statement report, and changed-resource extraction.
Reference sources:
- Legacy parser grammar and examples:
github.com/bytebase/parser/redshiftatv0.0.0-20260417075056-57b6ef7a2640. - Official syntax: Amazon Redshift SQL command documentation.
- Existing Bytebase consumers:
backend/plugin/parser/redshift,backend/common/engine.go, SQL Editor, export resources, statement report, and LSP completion.
Progress rules:
- A scenario passes only when a focused automated test proves the behavior.
- Legacy examples that parse today must not regress.
- Unsupported cases must fail explicitly; they must not produce misleading AST, query span, or completion results.
-
redshiftexposesParse(sql string) ([]Statement, error). -
redshift/parserexposes a hand-written recursive-descent parser forked from Omni PostgreSQL. -
redshift/astcontains Redshift AST nodes and walker support. -
redshift/catalogcan analyze PostgreSQL-compatible Redshift SELECT queries. -
redshift/completionexposes completion context for Redshift SQL. -
go test ./redshift/...runs without depending on Bytebase.
- All 115 legacy Redshift example files are available to tests or test fixtures.
- The corpus is classified into P0 parse, P1 parse, and unsupported/deferred groups.
- PostgreSQL-compatible examples from the legacy corpus parse successfully.
- Redshift-specific examples are tracked as expected failures until implemented.
- Corpus failures report the source file and first syntax error.
-
Splitseparates top-level semicolon-delimited statements. -
Splitignores semicolons inside single-quoted strings. -
Splitignores semicolons inside double-quoted identifiers. -
Splitignores semicolons inside dollar-quoted strings. -
Splitignores semicolons inside block comments. -
Splithandles Redshift procedure/function blocks without splitting internal statements.
-
SELECT 1parses as a select statement. -
WITH c AS (SELECT 1) SELECT * FROM cparses with a CTE. -
INSERT INTO t SELECT 1parses as DML. -
UPDATE t SET a = 1 WHERE id = 2parses as DML. -
DELETE FROM t WHERE id = 1parses as DML. -
MERGE INTO target USING source ON target.id = source.id WHEN MATCHED THEN UPDATE SET v = source.vparses as DML. -
MERGE ... REMOVE DUPLICATESparses as Redshift-specific MERGE. -
EXPLAIN SELECT 1parses as utility SQL. -
EXPLAIN ANALYZE SELECT 1parses and is classified distinctly from plain explain.
-
CREATE TABLE t (id INT)parses. -
CREATE TABLE t (id INT IDENTITY(1,1))parses and records identity options. -
CREATE TABLE t (id INT GENERATED BY DEFAULT AS IDENTITY)parses. -
CREATE TABLE t (name VARCHAR(32) ENCODE lzo)parses and records column encoding. -
CREATE TABLE t (id INT DISTKEY)parses and records column distkey. -
CREATE TABLE t (id INT SORTKEY)parses and records column sortkey. -
CREATE TABLE t (id INT) DISTSTYLE KEY DISTKEY(id)parses and records table distribution options. -
CREATE TABLE t (id INT) SORTKEY(id)parses and records compound sort key. -
CREATE TABLE t (id INT) INTERLEAVED SORTKEY(id)parses and records interleaved sort key. -
CREATE TABLE t (id INT) ENCODE AUTOparses and records automatic encoding. -
CREATE TABLE t (id INT) BACKUP NOparses and records backup behavior.
-
COPY t FROM 's3://bucket/file' IAM_ROLE DEFAULTparses. -
COPY t FROM 's3://bucket/file' IAM_ROLE 'arn:aws:iam::1:role/r' FORMAT AS CSVparses. -
COPY t FROM 's3://bucket/file' CREDENTIALS 'aws_access_key_id=...'parses. -
UNLOAD ('SELECT * FROM t') TO 's3://bucket/out' IAM_ROLE DEFAULTparses. -
UNLOADoptions parse forFORMAT,MANIFEST,HEADER,DELIMITER,ENCRYPTED, and compression.
-
SHOW DATABASESparses. -
SHOW DATABASES LIKE 'dev%' LIMIT 10parses. -
SHOW SCHEMAS FROM DATABASE dev LIMIT 10parses. -
SHOW TABLES FROM SCHEMA dev.public LIKE 't%' LIMIT 10parses. -
SHOW COLUMNS FROM TABLE public.tparses. -
SHOW GRANTS ON TABLE public.tparses. -
SHOW DATASHARESparses. -
DESC DATASHARE share_nameparses.
-
CREATE DATASHARE sparses. -
ALTER DATASHARE s ADD TABLE public.tparses. -
DROP DATASHARE IF EXISTS sparses. -
CREATE EXTERNAL SCHEMA s FROM DATA CATALOG DATABASE 'db' REGION 'us-east-1' IAM_ROLE DEFAULTparses. -
CREATE EXTERNAL TABLE s.t (id INT) STORED AS PARQUET LOCATION 's3://bucket/'parses. -
CREATE EXTERNAL VIEW v AS SELECT 1parses. -
CREATE MASKING POLICY p WITH (...) USING (...)parses or fails with explicit unsupported detail. -
ATTACH MASKING POLICY p ON t(c) TO ROLE rparses or fails with explicit unsupported detail. -
CREATE RLS POLICY p WITH (...) USING (...)parses or fails with explicit unsupported detail. -
CREATE MODEL m FROM (...) TARGET y FUNCTION f IAM_ROLE DEFAULTparses or fails with explicit unsupported detail.
-
Diagnosereturns no diagnostics for valid P0 Redshift SQL. -
Diagnosereturns a syntax diagnostic with line and column for invalid SQL. -
StatementRangesreturns UTF-16 LSP ranges for single-line SQL. -
StatementRangesreturns UTF-16 LSP ranges for multi-line SQL. -
StatementRangeshandles non-BMP characters before statement starts.
-
GetStatementTypesclassifies CREATE TABLE. -
GetStatementTypesclassifies ALTER TABLE. -
GetStatementTypesclassifies DROP TABLE. -
GetStatementTypesclassifies INSERT, UPDATE, DELETE, and MERGE as DML. -
ValidateSQLForEditorallows SELECT. -
ValidateSQLForEditorallows plain EXPLAIN. -
ValidateSQLForEditorallows SHOW statements. -
ValidateSQLForEditorrejects DML for read-only execution. -
ValidateSQLForEditorrejects DDL for read-only execution. -
ValidateSQLForEditortreats EXPLAIN ANALYZE non-SELECT conservatively.
-
ExtractChangedResourcesreports created tables. -
ExtractChangedResourcesreports dropped tables as affected resources. -
ExtractChangedResourcesreports altered tables as affected resources. -
ExtractChangedResourcescounts INSERT statements. -
ExtractChangedResourcescounts UPDATE statements. -
ExtractChangedResourcescounts DELETE statements. -
ExtractChangedResourcesrespectsSET search_path.
- Query span reports source columns for simple table columns.
- Query span expands
SELECT *from table metadata. - Query span expands table-qualified star.
- Query span tracks aliases in SELECT list.
- Query span tracks source columns inside expressions.
- Query span tracks predicate columns from WHERE.
- Query span tracks predicate columns from JOIN ON.
- Query span handles JOIN USING.
- Query span handles CTEs with explicit column aliases.
- Query span handles CTEs without explicit column aliases.
- Query span handles subquery table aliases.
- Query span handles set operations.
- Query span handles view definitions from metadata.
- Query span handles
QUALIFYas predicate context. - Query span handles
EXCLUDE (...)result shaping. - Query span handles
SELECT INTOas DML/DDL-like statement where appropriate. - Query span explicitly rejects unsupported
CONNECT BYlineage instead of returning wrong lineage.
- Completion suggests top-level SELECT/INSERT/UPDATE/DELETE/MERGE/CREATE/ALTER/DROP/COPY/UNLOAD/SHOW.
- Completion suggests schema names from metadata.
- Completion suggests table names from selected schema.
- Completion suggests columns after
SELECTwith FROM context. - Completion suggests columns after table alias dot.
- Completion suggests CTE names in FROM.
- Completion suggests CTE columns when aliases are explicit.
- Completion suggests subquery alias/output columns from syntax-derived target lists.
- Completion suggests
DISTKEY,SORTKEY,DISTSTYLE, andENCODEin CREATE TABLE option context. - Completion suggests
IAM_ROLE,CREDENTIALS, and format options in COPY context. - Completion suggests
IAM_ROLE,MANIFEST,HEADER, and format options in UNLOAD context. - Completion suggests SHOW subcommands.
- Completion does not invent metadata columns for unsupported shapes.
- Bytebase Redshift parser registration delegates parse/split/diagnose/ranges/types to Omni.
- Bytebase Redshift query validator delegates to Omni.
- Bytebase Redshift changed resources delegates to Omni.
- Bytebase Redshift query span delegates to Omni.
- Bytebase Redshift completion delegates to Omni.
- Bytebase no longer imports
github.com/bytebase/parser/redshifton the Redshift main path. - Bytebase focused Redshift parser tests pass.
- Bytebase SQL Editor validation tests pass for Redshift.
- Bytebase masking/query-span tests pass for Redshift.
- Bytebase statement report tests pass for Redshift.
- AWS Redshift SQL command reference is represented by an Omni-side manifest.
- Every manifest command has an explicit status: runtime-supported, parse-supported, explicitly unsupported, or not relevant.
- Runtime-supported command samples parse successfully.
- Parse-supported command samples parse successfully.
- Explicitly unsupported command samples fail instead of silently producing a misleading supported result.
- The matrix includes Redshift-specific commands such as
ALTER TABLE APPEND,ANALYZE COMPRESSION,COPY,UNLOAD,SHOW EXTERNAL TABLE,USE, andVACUUM.
- The 115-file legacy Redshift corpus is counted by a compatibility report.
- Expected-failure legacy files are counted separately from passing files.
- New legacy corpus failures fail the compatibility test.
- Legacy expected failures that start parsing are reported as promoted files and must be reclassified.
- Legacy corpus files are split into individual statements for old-parser-vs-Omni parity statistics.
- Statement-level gaps are reported with examples so the next support tranche can be prioritized.
- Compatibility verification checks Redshift CREATE TABLE options through
Parse. - Compatibility verification checks syntax diagnostics on invalid SQL.
- Compatibility verification checks UTF-16 statement ranges on multi-statement SQL.
- Compatibility verification checks Redshift command statement classification for COPY, UNLOAD, MERGE, and SHOW.
- Compatibility verification checks SQL Editor read-only validation for EXPLAIN and DML rejection.
- Compatibility verification checks changed-resource extraction for DDL and DML.
- Compatibility verification checks parser-native completion scope for FROM relations.
- Compatibility verification has an optional Redshift reference execution harness.
- The harness is disabled with an explicit skip reason when
REDSHIFT_COMPAT_DSNis not set. - The report records whether reference Redshift validation ran or was skipped.
- Omni can generate a Markdown Redshift compatibility report from the command manifest and legacy corpus.
- The checked-in compatibility report is tested for freshness.
- The report exposes command-level parse status, legacy file counts, legacy statement parity counts, runtime semantic counts, and reference Redshift status.