Skip to content

Commit 2957be4

Browse files
Improved dialect method documentation
1 parent 25b5e3e commit 2957be4

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

src/dialect/mod.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -180,47 +180,47 @@ pub trait Dialect: Debug + Any {
180180

181181
/// Returns whether the dialect supports hyphenated identifiers.
182182
///
183-
/// Hyphenated identifiers are identifiers that contain hyphens (dashes)
184-
/// within the name, such as `my-table` or `column-name`.
185-
///
186-
/// # Examples
187-
///
188-
/// BigQuery supports hyphenated identifiers:
183+
/// Hyphenated identifiers contain hyphens within the name (e.g., `my-table`).
184+
/// Supported by BigQuery for project, dataset, and table names.
189185
///
190186
/// ```rust
191187
/// # use sqlparser::{dialect::BigQueryDialect, parser::Parser};
192-
/// let dialect = BigQueryDialect;
193-
/// let sql = "SELECT my-column FROM my-table";
194-
/// let result = Parser::parse_sql(&dialect, sql);
195-
/// assert!(result.is_ok());
188+
/// let sql = "SELECT * FROM my-project.my-dataset.my-table";
189+
/// assert!(Parser::parse_sql(&BigQueryDialect, sql).is_ok());
196190
/// ```
197191
///
198-
/// Most other dialects do not support hyphenated identifiers,
199-
/// and in those cases such identifiers must be quoted:
192+
/// For dialects that do not support hyphenated identifiers,
193+
/// the parser will interpret the hyphen as a minus operator,
194+
/// and may result in a syntax error if the context is not valid.
200195
///
201196
/// ```rust
202197
/// # use sqlparser::{dialect::PostgreSqlDialect, parser::Parser};
203-
/// let dialect = PostgreSqlDialect {};
204-
/// let sql = "SELECT my-column FROM my-table";
205-
/// let result = Parser::parse_sql(&dialect, sql);
206-
/// assert!(result.is_err());
198+
/// let sql = "SELECT * FROM my-project.my-dataset.my-table";
199+
/// assert!(Parser::parse_sql(&PostgreSqlDialect{}, sql).is_err());
200+
/// ```
201+
fn supports_hyphenated_identifiers(&self) -> bool {
202+
false
203+
}
204+
205+
/// Returns whether the dialect supports path-like identifiers.
206+
///
207+
/// Path-like identifiers contain forward slashes for hierarchical paths
208+
/// (e.g., `@namespace.stage_name/path`). Used in Snowflake for stage locations.
209+
///
210+
/// ```rust
211+
/// # use sqlparser::{dialect::SnowflakeDialect, parser::Parser};
212+
/// let sql = "COPY INTO a.b FROM @namespace.stage_name/path";
213+
/// assert!(Parser::parse_sql(&SnowflakeDialect, sql).is_ok());
207214
/// ```
208215
///
209-
/// In dialects that do not support hyphenated identifiers, the above
210-
/// query would need to be written as:
216+
/// For dialects that do not support path-like identifiers,
217+
/// the parser will raise a syntax error when encountering such identifiers.
211218
///
212219
/// ```rust
213220
/// # use sqlparser::{dialect::PostgreSqlDialect, parser::Parser};
214-
/// let dialect = PostgreSqlDialect {};
215-
/// let sql = "SELECT \"my-column\" FROM \"my-table\"";
216-
/// let result = Parser::parse_sql(&dialect, sql);
217-
/// assert!(result.is_ok());
221+
/// let sql = "COPY INTO a.b FROM @namespace.stage_name/path";
222+
/// assert!(Parser::parse_sql(&PostgreSqlDialect{}, sql).is_err());
218223
/// ```
219-
fn supports_hyphenated_identifiers(&self) -> bool {
220-
false
221-
}
222-
223-
/// Returns whether the dialect supports path-like identifiers
224224
fn supports_path_like_identifiers(&self) -> bool {
225225
false
226226
}

0 commit comments

Comments
 (0)