Implement Spanned to retrieve source locations on AST nodes (#1435)

Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
This commit is contained in:
Mark-Oliver Junge 2024-11-26 17:22:30 +01:00 committed by GitHub
parent 0adec33b94
commit 3c8fd74804
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 3092 additions and 399 deletions

View file

@ -18,6 +18,8 @@
#[macro_use]
mod test_utils;
use helpers::attached_token::AttachedToken;
use sqlparser::tokenizer::Span;
use test_utils::*;
use sqlparser::ast::*;
@ -259,22 +261,18 @@ fn test_select_union_by_name() {
op: SetOperator::Union,
set_quantifier: *expected_quantifier,
left: Box::<SetExpr>::new(SetExpr::Select(Box::new(Select {
select_token: AttachedToken::empty(),
distinct: None,
top: None,
projection: vec![SelectItem::Wildcard(WildcardAdditionalOptions::default())],
top_before_distinct: false,
projection: vec![SelectItem::Wildcard(WildcardAdditionalOptions {
opt_ilike: None,
opt_exclude: None,
opt_except: None,
opt_rename: None,
opt_replace: None,
})],
into: None,
from: vec![TableWithJoins {
relation: TableFactor::Table {
name: ObjectName(vec![Ident {
value: "capitals".to_string(),
quote_style: None,
span: Span::empty(),
}]),
alias: None,
args: None,
@ -301,22 +299,18 @@ fn test_select_union_by_name() {
connect_by: None,
}))),
right: Box::<SetExpr>::new(SetExpr::Select(Box::new(Select {
select_token: AttachedToken::empty(),
distinct: None,
top: None,
projection: vec![SelectItem::Wildcard(WildcardAdditionalOptions::default())],
top_before_distinct: false,
projection: vec![SelectItem::Wildcard(WildcardAdditionalOptions {
opt_ilike: None,
opt_exclude: None,
opt_except: None,
opt_rename: None,
opt_replace: None,
})],
into: None,
from: vec![TableWithJoins {
relation: TableFactor::Table {
name: ObjectName(vec![Ident {
value: "weather".to_string(),
quote_style: None,
span: Span::empty(),
}]),
alias: None,
args: None,
@ -355,12 +349,28 @@ fn test_duckdb_install() {
Statement::Install {
extension_name: Ident {
value: "tpch".to_string(),
quote_style: None
quote_style: None,
span: Span::empty()
}
}
);
}
#[test]
fn test_duckdb_load_extension() {
let stmt = duckdb().verified_stmt("LOAD my_extension");
assert_eq!(
Statement::Load {
extension_name: Ident {
value: "my_extension".to_string(),
quote_style: None,
span: Span::empty()
}
},
stmt
);
}
#[test]
fn test_duckdb_struct_literal() {
//struct literal syntax https://duckdb.org/docs/sql/data_types/struct#creating-structs