Uh oh!
There was an error while loading. Please reload this page.
Update comments / docs for Spanned - #1549
Conversation
2092351 to
bb7ad71Compare| @@ -1,52 +0,0 @@ | |||
There was a problem hiding this comment.
This content is great. However, I think it may be hard to find given it is in a separate file
I moved the content into two places:
- docs in lib.rs for stuff that is relevant to users
- The [EPIC] Complete Span (source location) information / feature #1548 for things that are related to contributors
I think that will make it more likely the documentation can be discovered
d08e6ec to
ec24d26Compare| syntax from newer versions that have been explicitly requested, plus some MSSQL, | ||
| PostgreSQL, and other dialect-specific syntax. Whenever possible, the [online | ||
| SQL:2016 grammar][sql-2016-grammar] is used to guide what syntax to accept. | ||
| syntax from newer versions that have been explicitly requested, plus various |
| } | ||
| } | ||
| impl From<AttachedToken> for TokenWithLocation { |
There was a problem hiding this comment.
this seemed to be an obvious gap so I just added it to avoid a papercut
| /// | ||
| /// [this ticket]: https://github.com/apache/datafusion-sqlparser-rs/issues/1548 | ||
| /// | ||
| /// # Example |
There was a problem hiding this comment.
I felt an example will help people understand how to use the Spans
| //! [`ast`]: crate::ast | ||
| //! [`Dialect`]: crate::dialect::Dialect | ||
| //! | ||
| //! # Source Spans |
There was a problem hiding this comment.
This content is largely migrated from docs/source_spans.md
| #[cfg_attr(feature = "visitor", derive(Visit, VisitMut))] | ||
| pub struct Location { | ||
| /// Line number, starting from 1 | ||
| /// Line number, starting from 1. |
There was a problem hiding this comment.
/// means these comments show up in docs
| /// Create a new location for a given line and column | ||
| /// | ||
| /// Alias for [`Self::new`] | ||
| // TODO: remove / deprecate in favor of` `new` for consistency? |
There was a problem hiding this comment.
I found the Location::of API kind of confusing -- I would expect that creating a new Rust object would be done via ::new() so I added a new()
I am thinking perhaps we can deprecate Location::of maybe to help downstream users
| fn union_spans<I: Iterator<Item = Span>>(iter: I) -> Span { | ||
| iter.reduce(|acc, item| acc.union(&item)) | ||
| .unwrap_or(Span::empty()) | ||
| Span::union_iter(iter) |
There was a problem hiding this comment.
this was useful enough I felt making it a method in Span with more documentation and examples would make it easier to find
| /// Span::union_iter(spans), | ||
| /// Span::new(Location::new(1, 1), Location::new(4, 2)) | ||
| /// ); | ||
| pub fn union_iter<I: IntoIterator<Item = Span>>(iter: I) -> Span { |
There was a problem hiding this comment.
This was a private function and I thought it was useful enough it should be its own API and have an example, so I pulled it into a method
iffyio
left a comment
There was a problem hiding this comment.
LGTM! Thanks for the updates, the docs look great!
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| /// Create a new location for a given line and column | ||
| /// | ||
| /// Alias for [`Self::new`] | ||
| // TODO: remove / deprecate in favor of` `new` for consistency? |
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
alamb
commented
Nov 30, 2024
🚀 |
alamb
commented
Nov 30, 2024
into update * tag 'v0.53.0' of https://github.com/apache/datafusion-sqlparser-rs: (66 commits) Run cargo fmt in derive crate Add Apache license header to spans.rs Update version to 0.53.0 and add release notes (apache#1592) Add support for ODBC functions (apache#1585) Parse `INSERT` with subquery when lacking column names (apache#1586) Support INSERT OVERWRITE INTO syntax (apache#1584) Snowflake ALTER TABLE clustering options (apache#1579) Parse Snowflake USE ROLE and USE SECONDARY ROLES (apache#1578) Add support of the ENUM8|ENUM16 for ClickHouse dialect (apache#1574) Fix displaying WORK or TRANSACTION after BEGIN (apache#1565) Support parsing optional nulls handling for unique constraint (apache#1567) Support BIT column types (apache#1577) Encapsulate CreateFunction (apache#1573) Support Databricks struct literal (apache#1542) Update comments / docs for `Spanned` (apache#1549) Support snowflake double dot notation for object name (apache#1540) `json_object('k' VALUE 'v')` in postgres (apache#1547) Increase version of sqlparser_derive from 0.2.2 to 0.3.0 (apache#1571) Support MySQL size variants for BLOB and TEXT columns (apache#1564) Rename `TokenWithLocation` to `TokenWithSpan`, in backwards compatible way (apache#1562) ...
… into sqlitedollar * 'update' of github.com:AikidoSec/datafusion-sqlparser-rs: (66 commits) Run cargo fmt in derive crate Add Apache license header to spans.rs Update version to 0.53.0 and add release notes (apache#1592) Add support for ODBC functions (apache#1585) Parse `INSERT` with subquery when lacking column names (apache#1586) Support INSERT OVERWRITE INTO syntax (apache#1584) Snowflake ALTER TABLE clustering options (apache#1579) Parse Snowflake USE ROLE and USE SECONDARY ROLES (apache#1578) Add support of the ENUM8|ENUM16 for ClickHouse dialect (apache#1574) Fix displaying WORK or TRANSACTION after BEGIN (apache#1565) Support parsing optional nulls handling for unique constraint (apache#1567) Support BIT column types (apache#1577) Encapsulate CreateFunction (apache#1573) Support Databricks struct literal (apache#1542) Update comments / docs for `Spanned` (apache#1549) Support snowflake double dot notation for object name (apache#1540) `json_object('k' VALUE 'v')` in postgres (apache#1547) Increase version of sqlparser_derive from 0.2.2 to 0.3.0 (apache#1571) Support MySQL size variants for BLOB and TEXT columns (apache#1564) Rename `TokenWithLocation` to `TokenWithSpan`, in backwards compatible way (apache#1562) ...
I took a pass over the code in #1435 and found some places
I thought adding some more documentation would be helpful.
Changes
Follow on work (tickets)
TokenWithLocationtoTokenWithSpan, in backwards compatible way #1562