mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-13 07:22:02 +00:00
Document round trip ability (#1052)
This commit is contained in:
parent
86aa044032
commit
64eccdbba2
3 changed files with 46 additions and 1 deletions
20
src/lib.rs
20
src/lib.rs
|
@ -21,7 +21,7 @@
|
|||
//! 2. [`ast`] for the AST structure
|
||||
//! 3. [`Dialect`] for supported SQL dialects
|
||||
//!
|
||||
//! # Example
|
||||
//! # Example parsing SQL text
|
||||
//!
|
||||
//! ```
|
||||
//! use sqlparser::dialect::GenericDialect;
|
||||
|
@ -39,6 +39,24 @@
|
|||
//! println!("AST: {:?}", ast);
|
||||
//! ```
|
||||
//!
|
||||
//! # Creating SQL text from AST
|
||||
//!
|
||||
//! This crate allows users to recover the original SQL text (with normalized
|
||||
//! whitespace and identifier capitalization), which is useful for tools that
|
||||
//! analyze and manipulate SQL.
|
||||
//!
|
||||
//! ```
|
||||
//! # use sqlparser::dialect::GenericDialect;
|
||||
//! # use sqlparser::parser::Parser;
|
||||
//! let sql = "SELECT a FROM table_1";
|
||||
//!
|
||||
//! // parse to a Vec<Statement>
|
||||
//! let ast = Parser::parse_sql(&GenericDialect, sql).unwrap();
|
||||
//!
|
||||
//! // The original SQL text can be generated from the AST
|
||||
//! assert_eq!(ast[0].to_string(), sql);
|
||||
//! ```
|
||||
//!
|
||||
//! [sqlparser crates.io page]: https://crates.io/crates/sqlparser
|
||||
//! [`Parser::parse_sql`]: crate::parser::Parser::parse_sql
|
||||
//! [`Parser::new`]: crate::parser::Parser::new
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue