SQL Parser Coverage

Lexega includes dedicated parsers for seven SQL dialects — Snowflake, PostgreSQL, BigQuery, MySQL, MSSQL, Databricks, and Amazon Redshift. All parsed statements undergo semantic extraction for governance signal emission (see the Rule Reference for the full rule catalog).


Snowflake

DML (Data Manipulation)

  • SELECT (including CTEs, recursive CTEs, window functions, PIVOT/UNPIVOT, MATCH_RECOGNIZE)
  • INSERT (single/multi-value, subquery)
  • INSERT ALL / INSERT FIRST (multi-table conditional insert)
  • UPDATE (simple, multi-table)
  • DELETE
  • MERGE (with complex MATCHED/NOT MATCHED branches)
  • COPY INTO (stage → table, table → stage)
  • VALUES (standalone values queries)
  • SET operations (UNION, UNION ALL, INTERSECT, EXCEPT, MINUS)
  • Pipe syntax (SQL pipe chains)

DDL (Data Definition)

  • CREATE/ALTER/DROP: TABLE, VIEW, MATERIALIZED VIEW
  • CREATE/ALTER/DROP: STAGE, STREAM, TASK, PIPE, FILE FORMAT
  • CREATE/ALTER/DROP: DATABASE, SCHEMA
  • CREATE/ALTER/DROP: DYNAMIC TABLE
  • CREATE/ALTER/DROP: WAREHOUSE
  • CREATE/ALTER/DROP: FUNCTION, TABLE FUNCTION, PROCEDURE
  • CREATE EXTERNAL TABLE
  • TRUNCATE, SHOW, DESCRIBE/DESC, USE
  • UNDROP DATABASE, UNDROP SCHEMA, UNDROP TABLE
  • GRANT / REVOKE

Security & Governance Policies

  • CREATE/ALTER/DROP: MASKING POLICY
  • CREATE/ALTER/DROP: ROW ACCESS POLICY
  • DROP ALL ROW ACCESS POLICIES ON table
  • CREATE/ALTER/DROP: NETWORK POLICY
  • CREATE/ALTER/DROP: SESSION POLICY
  • CREATE/ALTER/DROP: PASSWORD POLICY
  • CREATE/ALTER/DROP: AGGREGATION POLICY
  • CREATE/ALTER/DROP: PROJECTION POLICY
  • CREATE/ALTER/DROP: AUTHENTICATION POLICY

Integrations

  • CREATE/ALTER/DROP: STORAGE INTEGRATION
  • CREATE/ALTER/DROP: API INTEGRATION
  • CREATE/ALTER/DROP: EXTERNAL ACCESS INTEGRATION

Snowflake Scripting

  • DECLARE, SET, LET
  • IF / ELSEIF / ELSE, CASE statement
  • FOR / WHILE / LOOP / REPEAT...UNTIL
  • BREAK / CONTINUE
  • BEGIN / END blocks with exception handling
  • RETURN statements
  • CALL (stored procedure invocation)
  • Cursors (DECLARE CURSOR, LET CURSOR, OPEN, FETCH, CLOSE)
  • EXECUTE IMMEDIATE (dynamic SQL)
  • RAISE (exception raising)
  • Transaction control (BEGIN TRANSACTION, COMMIT, ROLLBACK)
  • Async job management (AWAIT, CANCEL)

PostgreSQL

Full parsing and governance signal support for PostgreSQL-specific constructs.

DML

  • SELECT, INSERT, UPDATE, DELETE, MERGE (PostgreSQL 15+)
  • Common Table Expressions (WITH / WITH RECURSIVE)
  • UPSERT via INSERT ... ON CONFLICT DO NOTHING / DO UPDATE
  • COPY (TO / FROM with format options, including PROGRAM)
  • VALUES (standalone)

DDL

  • CREATE/ALTER/DROP TABLE (including IF EXISTS, IF NOT EXISTS, CASCADE)
  • CREATE/ALTER/DROP INDEX (including CONCURRENTLY, expression indexes)
  • CREATE/ALTER/DROP VIEW (including CREATE OR REPLACE)
  • CREATE/ALTER/DROP SCHEMA
  • CREATE/ALTER/DROP SEQUENCE (including OWNED BY)
  • CREATE/ALTER/DROP TYPE (composite types, enums, ranges, domains)
  • CREATE/ALTER/DROP DOMAIN (constraints, NOT NULL, defaults)
  • CREATE/ALTER/DROP FUNCTION / PROCEDURE (including LANGUAGE, RETURNS, body)
  • CREATE/ALTER/DROP TRIGGER (row-level, statement-level, BEFORE/AFTER/INSTEAD OF)
  • CREATE/ALTER/DROP EXTENSION (including CASCADE)
  • CREATE/ALTER/DROP TABLESPACE
  • CREATE/ALTER/DROP RULE (query rewrite rules)
  • CREATE AGGREGATE, CREATE OPERATOR
  • COMMENT ON (tables, columns, functions, schemas, types, indexes, views)
  • REFRESH MATERIALIZED VIEW (including CONCURRENTLY)

Security & Access Control

  • CREATE/ALTER/DROP ROLE (USER / ROLE / LOGIN recognized as distinct objects; role capabilities SUPERUSER, CREATEDB, CREATEROLE, LOGIN, INHERIT, REPLICATION, BYPASSRLS and their NO… negations are recognized)
  • GRANT / REVOKE (table, schema, sequence, function privileges; GROUP grantees)
  • Row Level Security: CREATE POLICY, ALTER POLICY, DROP POLICY
  • ALTER TABLE ... ENABLE/DISABLE TRIGGER
  • ALTER TABLE ... ENABLE/DISABLE/FORCE/NO FORCE ROW LEVEL SECURITY
  • DROP OWNED, REASSIGN OWNED

Data Management

  • TRUNCATE (with CASCADE, RESTART IDENTITY)
  • VACUUM, ANALYZE
  • CLUSTER, REINDEX
  • LISTEN, NOTIFY, UNLISTEN
  • LOCK TABLE (with lock modes)
  • DISCARD (session state reset)

Transaction & Session Control

  • BEGIN, COMMIT, ROLLBACK
  • SET (session parameters)
  • ALTER SYSTEM (server configuration)
  • PREPARE, EXECUTE, DEALLOCATE
  • EXPLAIN (with ANALYZE, VERBOSE, FORMAT)
  • DO (anonymous code blocks)

Replication

  • CREATE/ALTER PUBLICATION
  • CREATE/ALTER SUBSCRIPTION

BigQuery

Full parsing and governance signal support for BigQuery-specific constructs.

DML

  • SELECT, INSERT, UPDATE, DELETE, MERGE
  • Common Table Expressions (WITH)
  • ASSERT (with optional description)

DDL

  • CREATE/ALTER/DROP TABLE, VIEW, SCHEMA
  • CREATE/ALTER/DROP FUNCTION, PROCEDURE
  • CREATE/DROP SNAPSHOT TABLE
  • CREATE/DROP SEARCH INDEX
  • CREATE/ALTER/DROP VECTOR INDEX
  • CREATE EXTERNAL TABLE

Machine Learning (BQML)

  • CREATE/ALTER/DROP MODEL
  • EXPORT MODEL

Data Import/Export

  • EXPORT DATA (with connection options)
  • LOAD DATA (from external sources)

MySQL

Parsing, formatting, and risk analysis for the everyday MySQL 8.0 surface, including the prepared-statement dynamic-SQL chain.

Dialect-Aware Recognition

  • Backtick-quoted identifiers (`col`)
  • Double-quoted text as a string literal
  • # line comments (alongside -- and /* */)
  • || recognized as logical OR (not string concatenation)

DML

  • SELECT (CTEs, window functions with named windows, LIMIT offset, count, LOCK IN SHARE MODE, INTO OUTFILE/DUMPFILE, MATCH … AGAINST, GROUP_CONCAT(… SEPARATOR …), @v := assignment in queries)
  • Index hints on table references (USE | FORCE | IGNORE INDEX [FOR JOIN | ORDER BY | GROUP BY])
  • PARTITION (p, …) selection on table references (in queries and on UPDATE/DELETE targets)
  • TABLE statement (TABLE t ORDER BY … LIMIT …) — analyzed as a full query, composes in set operations, subqueries, INSERT sources, and CTAS
  • INSERT (ON DUPLICATE KEY UPDATE, INSERT SET, VALUES ROW(…), IGNORE/LOW_PRIORITY, optional INTO, PARTITION targets, row alias AS new)
  • REPLACE INTO
  • UPDATE / DELETE (trailing ORDER BY … LIMIT, multi-table forms UPDATE t1 JOIN t2 … / DELETE t1, t2 FROM …, LOW_PRIORITY/IGNORE/QUICK)
  • Shared cross-dialect DML/DDL grammar (see Cross-Dialect Features), including ALTER TABLE … ADD COLUMN with the full attribute tail (UNSIGNED, AUTO_INCREMENT, …)

Prepared Statements & Dynamic SQL

  • PREPARE … FROM (string literal or @var), EXECUTE … USING @a, @b, DEALLOCATE / DROP PREPARE
  • SET @sql := CONCAT(…) → PREPARE → EXECUTE chains flow through dynamic-SQL analysis: concatenated input fires DYNSQL-CONCAT / DYNSQL; static literals stay silent

Session & Variables

  • SET for @user and @@system variables — GLOBAL/SESSION scopes, = and :=, multi-assignment lists
  • SET NAMES / CHARACTER SET, SET PASSWORD, SET ROLE / DEFAULT ROLE, SET TRANSACTION

Access Control

  • GRANT / REVOKE — MySQL priv_level forms (*.* server-wide, db.*, db.tbl), 'user'@'host' grantees, WITH GRANT OPTION

Statements outside this surface — trigger/function/event bodies, LOAD DATA INFILE, XA/savepoint transaction statements — are counted as skipped in the report summary.


MSSQL (SQL Server)

Full parsing, formatting, and risk analysis for Microsoft SQL Server / T-SQL constructs.

DML

  • SELECT (including TOP, CTEs, window functions, PIVOT/UNPIVOT with result column aliasing)
  • INSERT, UPDATE, DELETE (including TOP)
  • MERGE (with OUTPUT clause, preceding CTEs)
  • BULK INSERT (external file loading with table and file path tracking)
  • VALUES (standalone)

DDL

  • CREATE/ALTER/DROP TABLE, VIEW, SCHEMA
  • CREATE/ALTER/DROP FUNCTION, PROCEDURE (including CREATE OR ALTER)
  • CREATE/ALTER/DROP TRIGGER (DML and DDL triggers, CREATE OR ALTER)

Procedural / T-SQL

  • EXEC / EXECUTE (stored procedure calls, dynamic SQL detection)
  • TRY / CATCH blocks
  • IF / ELSE, WHILE
  • DECLARE (scalar and @var TABLE types)
  • SET session options (including IDENTITY_INSERT, NOCOUNT, etc.)
  • PRINT, THROW, RAISERROR
  • GO batch separator
  • Transaction control (BEGIN TRANSACTION, COMMIT, ROLLBACK)

Query Extensions

  • Table hints: NOLOCK, READUNCOMMITTED, TABLOCKX, XLOCK, HOLDLOCK, INDEX, FORCESEEK, FORCESCAN, etc.
  • FOR JSON (AUTO, PATH, ROOT) / FOR XML (AUTO, PATH, RAW, EXPLICIT)
  • OPENJSON, OPENXML, OPENROWSET

Access Control

  • GRANT / REVOKE / DENY (including DENY ALL, DENY ... TO PUBLIC, CASCADE, AS principal)

Governance Signals

  • Table hint detection (dirty reads, exclusive locks, forced index overrides)
  • Dynamic SQL detection (EXEC('...'), EXEC(@var))
  • BULK INSERT monitoring (file path and table tracking)
  • IDENTITY_INSERT state changes
  • Session option auditing
  • DENY privilege analysis
  • Trigger lifecycle tracking (create, modify, drop)
  • Stored procedure call tracking

Databricks

Full parsing and governance signal support for Databricks / Delta Lake constructs.

DML

  • SELECT, INSERT, UPDATE, DELETE, MERGE (with schema evolution)
  • Common Table Expressions (WITH)

DDL

  • CREATE/ALTER/DROP: TABLE, VIEW, SCHEMA
  • CREATE/ALTER/DROP: CATALOG
  • CREATE/ALTER/DROP: VOLUME
  • CREATE/ALTER/DROP: EXTERNAL LOCATION
  • CREATE/ALTER/DROP: STORAGE CREDENTIAL
  • CREATE/ALTER/DROP: CONNECTION
  • CREATE FLOW
  • CACHE TABLE / UNCACHE TABLE

Delta Lake Operations

  • OPTIMIZE (table compaction)
  • DESCRIBE HISTORY (table history)
  • REPAIR TABLE (partition metadata repair)
  • RESTORE TABLE (time travel restore)
  • Shallow clones (CREATE TABLE ... SHALLOW CLONE)

Access Control

  • GRANT / REVOKE (catalog, schema, volume, external location privileges)
  • Ownership transfer via ALTER

Amazon Redshift

Forked from PostgreSQL, so the PostgreSQL DML/DDL grammar applies, with dedicated coverage for Redshift's bulk-I/O, data-sharing, and Spectrum constructs.

DML

  • SELECT, INSERT, UPDATE, DELETE
  • Common Table Expressions (WITH)
  • APPROXIMATE aggregate modifier (APPROXIMATE COUNT(DISTINCT …))
  • Projection-level trailing EXCLUDE clause; SIMILAR TO

DDL

  • CREATE/ALTER/DROP: TABLE, VIEW, SCHEMA
  • Physical layout attributes: DISTSTYLE (incl. ALL), DISTKEY, SORTKEY (compound / interleaved), BACKUP NO
  • CREATE EXTERNAL SCHEMA (Spectrum — Glue Data Catalog / Hive Metastore / federated) and external tables

Bulk I/O

  • COPY — bulk load from S3 / EMR / DynamoDB / SSH, with format and load options, inline credentials, and psql variable placeholders (:var, :'var')
  • UNLOAD — export query results to an external location

Data Sharing

  • CREATE / ALTER DATASHARE — ADD / REMOVE objects, SET PUBLICACCESSIBLE, SET INCLUDENEW

Access Control

  • GRANT / REVOKE (PostgreSQL-derived, including GROUP grantees)

Cross-Dialect Features

These features work across all supported dialects.

Expressions & Query Constructs

The expression parser is shared across all dialects and covers:

  • Arithmetic, comparison, logical, and string operators
  • CASE / IIF / COALESCE / NULLIF / TRY_CAST / CAST
  • Subqueries (scalar, EXISTS, IN, ANY/ALL)
  • Window functions (OVER, PARTITION BY, ORDER BY, frame specification)
  • Aggregate functions (COUNT, SUM, AVG, etc. with DISTINCT, FILTER, WITHIN GROUP)
  • BETWEEN, LIKE, ILIKE, SIMILAR TO, RLIKE
  • ARRAY / OBJECT / STRUCT constructors
  • Semi-structured access (dot notation, bracket notation, :: casting)
  • LATERAL, FLATTEN, TABLE functions
  • Qualified names (schema.table.column)
  • INTERVAL, AT TIME ZONE

Need Help?

Can't find what you're looking for? Check out our GitHub or reach out to support.