@@ -41,7 +41,7 @@ void testParseAndDeparseJoin() throws JSQLParserException {
41
41
}
42
42
43
43
@ Test
44
- void testParseAndDeparseWith () throws JSQLParserException {
44
+ void testParseAndDeparseWithIssue73 () throws JSQLParserException {
45
45
// formatter:off
46
46
String sqlStr =
47
47
"with client_info as (\n " +
@@ -80,4 +80,42 @@ void testParseAndDeparseWith() throws JSQLParserException {
80
80
// formatter:on
81
81
TestUtils .assertSqlCanBeParsedAndDeparsed (sqlStr , true );
82
82
}
83
+
84
+ @ Test
85
+ void testParseAndDeparseWithJoinIssue72 () throws JSQLParserException {
86
+ // formatter:off
87
+ String sqlStr =
88
+ "with client as (\n " +
89
+ " select 1 as client_id\n " +
90
+ " |> UNION ALL\n " +
91
+ " (select 2),\n " +
92
+ " (select 3)\n " +
93
+ "), basket as (\n " +
94
+ " select 1 as basket_id, 1 as client_id\n " +
95
+ " |> UNION ALL\n " +
96
+ " (select 2, 2)\n " +
97
+ "), basket_item as (\n " +
98
+ " select 1 as item_id, 1 as basket_id\n " +
99
+ " |> UNION ALL\n " +
100
+ " (select 2, 1),\n " +
101
+ " (select 3, 1),\n " +
102
+ " (select 4, 2)\n " +
103
+ "), item as (\n " +
104
+ " select 1 as item_id, 'milk' as name\n " +
105
+ " |> UNION ALL\n " +
106
+ " (select 2, \" chocolate\" ),\n " +
107
+ " (select 3, \" donut\" ),\n " +
108
+ " (select 4, \" croissant\" )\n " +
109
+ ")\n " +
110
+ "FROM client c\n " +
111
+ " left join basket b using(client_id)\n " +
112
+ " left join basket_item bi using(basket_id)\n " +
113
+ " left join item i on i.item_id = bi.item_id\n " +
114
+ "|> aggregate count(i.item_id) as bought_item\n " +
115
+ " group by c.client_id, i.item_id, i.name\n " +
116
+ "|> aggregate array_agg((select as struct item_id, name, bought_item)) as items_info\n " +
117
+ " group by client_id" ;
118
+ // formatter:on
119
+ TestUtils .assertSqlCanBeParsedAndDeparsed (sqlStr , true );
120
+ }
83
121
}
0 commit comments