@@ -10947,20 +10947,14 @@ fn parse_unpivot_table() {
1094710947 index_hints: vec![],
1094810948 }),
1094910949 null_inclusion: None,
10950- value: vec![Ident {
10951- value: "quantity".to_string(),
10952- quote_style: None,
10953- span: Span::empty(),
10954- }],
10955-
10956- name: Ident {
10957- value: "quarter".to_string(),
10958- quote_style: None,
10959- span: Span::empty(),
10960- },
10950+ value: Expr::Identifier(Ident::new("quantity")),
10951+ name: Ident::new("quarter"),
1096110952 columns: ["Q1", "Q2", "Q3", "Q4"]
1096210953 .into_iter()
10963- .map(|col| IdentsWithAlias::new(vec![Ident::new(col)], None))
10954+ .map(|col| ExprWithAlias {
10955+ expr: Expr::Identifier(Ident::new(col)),
10956+ alias: None,
10957+ })
1096410958 .collect(),
1096510959 alias: Some(TableAlias {
1096610960 name: Ident::new("u"),
@@ -11024,31 +11018,46 @@ fn parse_unpivot_table() {
1102411018 );
1102511019
1102611020 let sql_unpivot_with_alias = concat!(
11027- "SELECT * FROM sales AS s ",
11028- "UNPIVOT INCLUDE NULLS (quantity FOR quarter IN (Q1 AS Quater1, Q2 AS Quater2, Q3 AS Quater3, Q4 AS Quater4)) AS u (product, quarter, quantity)"
11029- );
11021+ "SELECT * FROM sales AS s ",
11022+ "UNPIVOT INCLUDE NULLS ",
11023+ "(quantity FOR quarter IN ",
11024+ "(Q1 AS Quater1, Q2 AS Quater2, Q3 AS Quater3, Q4 AS Quater4)) ",
11025+ "AS u (product, quarter, quantity)"
11026+ );
1103011027
1103111028 if let Unpivot { value, columns, .. } =
1103211029 &verified_only_select(sql_unpivot_with_alias).from[0].relation
1103311030 {
1103411031 assert_eq!(
1103511032 *columns,
1103611033 vec![
11037- IdentsWithAlias::new(vec![Ident::new("Q1")], Some(Ident::new("Quater1"))),
11038- IdentsWithAlias::new(vec![Ident::new("Q2")], Some(Ident::new("Quater2"))),
11039- IdentsWithAlias::new(vec![Ident::new("Q3")], Some(Ident::new("Quater3"))),
11040- IdentsWithAlias::new(vec![Ident::new("Q4")], Some(Ident::new("Quater4"))),
11034+ ExprWithAlias {
11035+ expr: Expr::Identifier(Ident::new("Q1")),
11036+ alias: Some(Ident::new("Quater1")),
11037+ },
11038+ ExprWithAlias {
11039+ expr: Expr::Identifier(Ident::new("Q2")),
11040+ alias: Some(Ident::new("Quater2")),
11041+ },
11042+ ExprWithAlias {
11043+ expr: Expr::Identifier(Ident::new("Q3")),
11044+ alias: Some(Ident::new("Quater3")),
11045+ },
11046+ ExprWithAlias {
11047+ expr: Expr::Identifier(Ident::new("Q4")),
11048+ alias: Some(Ident::new("Quater4")),
11049+ },
1104111050 ]
1104211051 );
11043- assert_eq!(*value, vec![ Ident::new("quantity")] );
11052+ assert_eq!(*value, Expr::Identifier( Ident::new("quantity")) );
1104411053 }
1104511054
1104611055 assert_eq!(
1104711056 verified_stmt(sql_unpivot_with_alias).to_string(),
1104811057 sql_unpivot_with_alias
1104911058 );
1105011059
11051- let sql_unpivot_with_alias = concat!(
11060+ let sql_unpivot_with_alias_and_multi_value = concat!(
1105211061 "SELECT * FROM sales AS s ",
1105311062 "UNPIVOT INCLUDE NULLS ((first_quarter, second_quarter) ",
1105411063 "FOR half_of_the_year IN (",
@@ -11058,30 +11067,39 @@ fn parse_unpivot_table() {
1105811067 );
1105911068
1106011069 if let Unpivot { value, columns, .. } =
11061- &verified_only_select(sql_unpivot_with_alias ).from[0].relation
11070+ &verified_only_select(sql_unpivot_with_alias_and_multi_value ).from[0].relation
1106211071 {
1106311072 assert_eq!(
1106411073 *columns,
1106511074 vec![
11066- IdentsWithAlias::new(
11067- vec![Ident::new("Q1"), Ident::new("Q2")],
11068- Some(Ident::new("H1"))
11069- ),
11070- IdentsWithAlias::new(
11071- vec![Ident::new("Q3"), Ident::new("Q4")],
11072- Some(Ident::new("H2"))
11073- ),
11075+ ExprWithAlias {
11076+ expr: Expr::Tuple(vec![
11077+ Expr::Identifier(Ident::new("Q1")),
11078+ Expr::Identifier(Ident::new("Q2")),
11079+ ]),
11080+ alias: Some(Ident::new("H1")),
11081+ },
11082+ ExprWithAlias {
11083+ expr: Expr::Tuple(vec![
11084+ Expr::Identifier(Ident::new("Q3")),
11085+ Expr::Identifier(Ident::new("Q4")),
11086+ ]),
11087+ alias: Some(Ident::new("H2")),
11088+ },
1107411089 ]
1107511090 );
1107611091 assert_eq!(
1107711092 *value,
11078- vec![Ident::new("first_quarter"), Ident::new("second_quarter")]
11093+ Expr::Tuple(vec![
11094+ Expr::Identifier(Ident::new("first_quarter")),
11095+ Expr::Identifier(Ident::new("second_quarter")),
11096+ ])
1107911097 );
1108011098 }
1108111099
1108211100 assert_eq!(
11083- verified_stmt(sql_unpivot_with_alias ).to_string(),
11084- sql_unpivot_with_alias
11101+ verified_stmt(sql_unpivot_with_alias_and_multi_value ).to_string(),
11102+ sql_unpivot_with_alias_and_multi_value
1108511103 );
1108611104}
1108711105
@@ -11180,20 +11198,14 @@ fn parse_pivot_unpivot_table() {
1118011198 index_hints: vec![],
1118111199 }),
1118211200 null_inclusion: None,
11183- value: vec![Ident {
11184- value: "population".to_string(),
11185- quote_style: None,
11186- span: Span::empty()
11187- }],
11188-
11189- name: Ident {
11190- value: "year".to_string(),
11191- quote_style: None,
11192- span: Span::empty()
11193- },
11201+ value: Expr::Identifier(Ident::new("population")),
11202+ name: Ident::new("year"),
1119411203 columns: ["population_2000", "population_2010"]
1119511204 .into_iter()
11196- .map(|col| IdentsWithAlias::new(vec![Ident::new(col)], None))
11205+ .map(|col| ExprWithAlias {
11206+ expr: Expr::Identifier(Ident::new(col)),
11207+ alias: None,
11208+ })
1119711209 .collect(),
1119811210 alias: Some(TableAlias {
1119911211 name: Ident::new("u"),
0 commit comments