pub trait Spanned {
// Required method
fn span(&self) -> Span;
}
Expand description
Trait for AST nodes that have a source location information.
§Notes:
Source Span
are not yet complete. They may be missing:
- keywords or other tokens
- span information entirely, in which case they return
Span::empty()
.
Note Some impl blocks (rendered below) are annotated with which nodes are missing spans. See this ticket for additional information and status.
§Example
let dialect = GenericDialect {};
let sql = r#"SELECT *
FROM table_1"#;
let statements = Parser::new(&dialect)
.try_with_sql(sql)?
.parse_statements()?;
// Get the span of the first statement (SELECT)
let span = statements[0].span();
// statement starts at line 1, column 1 (1 based, not 0 based)
assert_eq!(span.start, Location::new(1, 1));
// statement ends on line 2, column 15
assert_eq!(span.end, Location::new(2, 15));
Required Methods§
Implementors§
impl Spanned for AccessExpr
impl Spanned for AlterColumnOperation
§partial span
Missing spans:
impl Spanned for AlterIndexOperation
impl Spanned for AlterTableOperation
§partial span
Missing spans:
impl Spanned for AssignmentTarget
impl Spanned for ColumnOption
§partial span
Missing spans:
impl Spanned for ConflictTarget
impl Spanned for CopySource
impl Spanned for CreateTableOptions
impl Spanned for ExcludeSelectItem
impl Spanned for Expr
§partial span
Most expressions are missing keywords in their spans.
f.e. IS NULL <expr>
reports as <expr>::span
.
Missing spans:
- Expr::TypedString
- Expr::MatchAgainst # MySQL specific
- Expr::RLike # MySQL specific
- Expr::Struct # BigQuery specific
- Expr::Named # BigQuery specific
- Expr::Dictionary # DuckDB specific
- Expr::Map # DuckDB specific
- Expr::Lambda
impl Spanned for FromTable
impl Spanned for FunctionArg
impl Spanned for FunctionArgExpr
§partial span
Missing spans:
impl Spanned for FunctionArgumentClause
impl Spanned for FunctionArguments
§partial span
The span of FunctionArguments::None is empty.
impl Spanned for GroupByExpr
§partial span
Missing spans:
impl Spanned for JoinConstraint
§partial span
Missing spans:
impl Spanned for JoinOperator
§partial span
Missing spans:
impl Spanned for JsonPathElem
§partial span
Missing spans:
impl Spanned for MatchRecognizePattern
§missing span
impl Spanned for OnConflictAction
§partial span
Missing spans:
impl Spanned for OnInsert
impl Spanned for Partition
impl Spanned for PivotValueSource
impl Spanned for ReferentialAction
§missing span
impl Spanned for RenameSelectItem
impl Spanned for SelectItem
impl Spanned for SetExpr
§partial span
SetExpr::Table is not implemented.
impl Spanned for SqlOption
impl Spanned for Statement
§partial span
Missing spans:
- Statement::CopyIntoSnowflake
- Statement::CreateSecret
- Statement::CreateRole
- Statement::AlterRole
- Statement::AttachDatabase
- Statement::AttachDuckDBDatabase
- Statement::DetachDuckDBDatabase
- Statement::Drop
- Statement::DropFunction
- Statement::DropProcedure
- Statement::DropSecret
- Statement::Declare
- Statement::CreateExtension
- Statement::Fetch
- Statement::Flush
- Statement::Discard
- Statement::SetRole
- Statement::SetVariable
- Statement::SetTimeZone
- Statement::SetNames
- Statement::SetNamesDefault
- Statement::ShowFunctions
- Statement::ShowVariable
- Statement::ShowStatus
- Statement::ShowVariables
- Statement::ShowCreate
- Statement::ShowColumns
- Statement::ShowTables
- Statement::ShowCollation
- Statement::StartTransaction
- Statement::SetTransaction
- Statement::Comment
- Statement::Commit
- Statement::Rollback
- Statement::CreateSchema
- Statement::CreateDatabase
- Statement::CreateFunction
- Statement::CreateTrigger
- Statement::DropTrigger
- Statement::CreateProcedure
- Statement::CreateMacro
- Statement::CreateStage
- Statement::Assert
- Statement::Grant
- Statement::Revoke
- Statement::Deallocate
- Statement::Execute
- Statement::Prepare
- Statement::Kill
- Statement::ExplainTable
- Statement::Explain
- Statement::Savepoint
- Statement::ReleaseSavepoint
- Statement::Merge
- Statement::Cache
- Statement::UNCache
- Statement::CreateSequence
- Statement::CreateType
- Statement::Pragma
- Statement::LockTables
- Statement::UnlockTables
- Statement::Unload
- Statement::OptimizeTable
impl Spanned for Subscript
impl Spanned for TableConstraint
impl Spanned for TableFactor
§partial span
Missing spans:
impl Spanned for TableObject
impl Spanned for TableOptionsClustered
§partial span
Missing spans:
impl Spanned for UpdateTableFromKind
impl Spanned for Use
impl Spanned for Value
§missing span
The span of a Value
is currently not implemented, as doing so
requires a breaking changes, which may be done in a future release.
impl Spanned for Array
impl Spanned for Assignment
impl Spanned for ClusteredIndex
impl Spanned for ColumnDef
impl Spanned for ColumnOptionDef
impl Spanned for ConnectBy
impl Spanned for ConstraintCharacteristics
§missing span
impl Spanned for CreateIndex
impl Spanned for CreateTable
impl Spanned for Cte
impl Spanned for Delete
impl Spanned for DoUpdate
impl Spanned for ExceptSelectItem
impl Spanned for ExprWithAlias
impl Spanned for Fetch
impl Spanned for Function
impl Spanned for FunctionArgumentList
impl Spanned for IlikeSelectItem
§missing span
impl Spanned for Insert
§partial span
Missing spans:ever
impl Spanned for Interpolate
impl Spanned for InterpolateExpr
impl Spanned for Join
impl Spanned for JsonPath
§partial span
see Spanned impl for JsonPathElem for more information