Skip to content

Commit 131ffd7

Browse files
committed
feat: change Tag.key to ObjectName
1 parent d74df47 commit 131ffd7

3 files changed

Lines changed: 35 additions & 16 deletions

File tree

src/ast/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9198,12 +9198,12 @@ impl Display for RowAccessPolicy {
91989198
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
91999199
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
92009200
pub struct Tag {
9201-
pub key: Ident,
9201+
pub key: ObjectName,
92029202
pub value: String,
92039203
}
92049204

92059205
impl Tag {
9206-
pub fn new(key: Ident, value: String) -> Self {
9206+
pub fn new(key: ObjectName, value: String) -> Self {
92079207
Self { key, value }
92089208
}
92099209
}

src/parser/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7864,7 +7864,7 @@ impl<'a> Parser<'a> {
78647864
}
78657865

78667866
pub(crate) fn parse_tag(&mut self) -> Result<Tag, ParserError> {
7867-
let name = self.parse_identifier()?;
7867+
let name = self.parse_object_name(false)?;
78687868
self.expect_token(&Token::Eq)?;
78697869
let value = self.parse_literal_string()?;
78707870

tests/sqlparser_snowflake.rs

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ fn test_snowflake_create_table_with_tag() {
270270
assert_eq!("my_table", name.to_string());
271271
assert_eq!(
272272
Some(vec![
273-
Tag::new("A".into(), "TAG A".to_string()),
274-
Tag::new("B".into(), "TAG B".to_string())
273+
Tag::new(ObjectName::from(vec![Ident::new("A")]), "TAG A".to_string()),
274+
Tag::new(ObjectName::from(vec![Ident::new("B")]), "TAG B".to_string())
275275
]),
276276
with_tags
277277
);
@@ -291,8 +291,8 @@ fn test_snowflake_create_table_with_tag() {
291291
assert_eq!("my_table", name.to_string());
292292
assert_eq!(
293293
Some(vec![
294-
Tag::new("A".into(), "TAG A".to_string()),
295-
Tag::new("B".into(), "TAG B".to_string())
294+
Tag::new(ObjectName::from(vec![Ident::new("A")]), "TAG A".to_string()),
295+
Tag::new(ObjectName::from(vec![Ident::new("B")]), "TAG B".to_string())
296296
]),
297297
with_tags
298298
);
@@ -765,8 +765,14 @@ fn test_snowflake_create_table_with_columns_tags() {
765765
option: ColumnOption::Tags(TagsColumnOption {
766766
with,
767767
tags: vec![
768-
Tag::new("A".into(), "TAG A".into()),
769-
Tag::new("B".into(), "TAG B".into()),
768+
Tag::new(
769+
ObjectName::from(vec![Ident::new("A")]),
770+
"TAG A".into()
771+
),
772+
Tag::new(
773+
ObjectName::from(vec![Ident::new("B")]),
774+
"TAG B".into()
775+
),
770776
]
771777
}),
772778
}],
@@ -819,8 +825,14 @@ fn test_snowflake_create_table_with_several_column_options() {
819825
option: ColumnOption::Tags(TagsColumnOption {
820826
with: true,
821827
tags: vec![
822-
Tag::new("A".into(), "TAG A".into()),
823-
Tag::new("B".into(), "TAG B".into()),
828+
Tag::new(
829+
ObjectName::from(vec![Ident::new("A")]),
830+
"TAG A".into()
831+
),
832+
Tag::new(
833+
ObjectName::from(vec![Ident::new("B")]),
834+
"TAG B".into()
835+
),
824836
]
825837
}),
826838
}
@@ -851,8 +863,14 @@ fn test_snowflake_create_table_with_several_column_options() {
851863
option: ColumnOption::Tags(TagsColumnOption {
852864
with: false,
853865
tags: vec![
854-
Tag::new("C".into(), "TAG C".into()),
855-
Tag::new("D".into(), "TAG D".into()),
866+
Tag::new(
867+
ObjectName::from(vec![Ident::new("C")]),
868+
"TAG C".into()
869+
),
870+
Tag::new(
871+
ObjectName::from(vec![Ident::new("D")]),
872+
"TAG D".into()
873+
),
856874
]
857875
}),
858876
}
@@ -905,8 +923,8 @@ fn test_snowflake_create_iceberg_table_all_options() {
905923
with_aggregation_policy.map(|name| name.to_string())
906924
);
907925
assert_eq!(Some(vec![
908-
Tag::new("A".into(), "TAG A".into()),
909-
Tag::new("B".into(), "TAG B".into()),
926+
Tag::new(ObjectName::from(vec![Ident::new("A")]), "TAG A".into()),
927+
Tag::new(ObjectName::from(vec![Ident::new("B")]), "TAG B".into()),
910928
]), with_tags);
911929

912930
}
@@ -4056,6 +4074,7 @@ fn test_snowflake_create_view_with_tag() {
40564074

40574075
#[test]
40584076
fn test_snowflake_create_view_with_tag_and_comment() {
4059-
let create_view_with_tag_and_comment = r#"CREATE VIEW X (COL WITH TAG (pii='email') COMMENT 'foobar') AS SELECT * FROM Y"#;
4077+
let create_view_with_tag_and_comment =
4078+
r#"CREATE VIEW X (COL WITH TAG (pii='email') COMMENT 'foobar') AS SELECT * FROM Y"#;
40604079
snowflake().verified_stmt(create_view_with_tag_and_comment);
40614080
}

0 commit comments

Comments
 (0)