Skip to main content

Crate spark_sql_parser

Crate spark_sql_parser 

Source
Expand description

Parse SQL into sqlparser AST.

Supports a Spark-style subset: single-statement SELECT, CREATE SCHEMA/DATABASE, and DROP TABLE/VIEW/SCHEMA, plus many DDL and utility statements (CREATE/ALTER/DROP TABLE/VIEW/FUNCTION/SCHEMA, SHOW, INSERT, DESCRIBE, SET, RESET, CACHE, EXPLAIN, etc.).

§SELECT and query compatibility

Any statement that sqlparser parses as a Query (e.g. SELECT, WITH ... SELECT) is accepted. Clause support is determined by sqlparser and the dialect in use (this crate uses GenericDialect).

§Known gaps

Spark-specific query clauses such as DISTRIBUTE BY, CLUSTER BY, SORT BY may not be recognized by the parser or may be rejected; behavior depends on the upstream dialect and parser. Use single-statement queries only (one statement per call).

Modules§

ast
Re-export of sqlparser::ast so consumers can depend only on spark-sql-parser for SQL AST types. SQL Abstract Syntax Tree (AST) types

Structs§

ParseError
Error returned when SQL parsing or validation fails.

Enums§

SparkStatement
Spark-oriented statement variants that are not reliably represented by upstream sqlparser AST.

Functions§

parse_select_expr
Parse a single SQL expression string (optionally with an alias) into sqlparser expression AST.
parse_spark_sql
Parse a Spark/PySpark-compatible SQL string.
parse_sql
Parse a single SQL statement (SELECT or DDL: CREATE SCHEMA / CREATE DATABASE / DROP TABLE/VIEW/SCHEMA).