Skip to content

Commit 297ef84

Browse files
fix: DuckDB STRUCT
Signed-off-by: Andreas Reichel <[email protected]>
1 parent aaebe59 commit 297ef84

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6902,12 +6902,13 @@ StructType StructType() #StruckType:
69026902
|
69036903
(
69046904
<OPENING_CURLY_BRACKET> { arguments= new ArrayList<SelectItem<?>>(); dialect = StructType.Dialect.DUCKDB;}
6905-
6906-
id = RelObjectName() <DOUBLE_COLON> expression = Expression() { arguments.add( new SelectItem( expression, id) ); }
6905+
( id = RelObjectNameExt2() | tk1=<S_CHAR_LITERAL> { id = tk1.image; } )
6906+
<DOUBLE_COLON> expression = Expression() { arguments.add( new SelectItem( expression, id) ); }
69076907

69086908
(
69096909
","
6910-
id = RelObjectName() <DOUBLE_COLON> expression = Expression() { arguments.add( new SelectItem( expression, id) ); }
6910+
( id = RelObjectNameExt2() | tk1=<S_CHAR_LITERAL> { id = tk1.image; } )
6911+
<DOUBLE_COLON> expression = Expression() { arguments.add( new SelectItem( expression, id) ); }
69116912
)*
69126913
<CLOSING_CURLY_BRACKET>
69136914

src/test/java/net/sf/jsqlparser/expression/StructTypeTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ void testStructTypeBigQuery() throws JSQLParserException {
3939

4040
@Test
4141
void testStructTypeDuckDB() throws JSQLParserException {
42-
// @todo: check why the white-space after the "{" is needed?!
4342
String sqlStr = "SELECT { t:'abc',len:5}";
4443
TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true);
4544

@@ -64,6 +63,12 @@ void testStructTypeConstructorDuckDB() throws JSQLParserException {
6463
TestUtils.assertStatementCanBeDeparsedAs(select, sqlStr, true);
6564
}
6665

66+
@Test
67+
void testStructTypeConstructorDuckDBWithQuotesAndTypes() throws JSQLParserException {
68+
String sqlStr = "SELECT {'t':'abc'::STRING,'len':5::INT}";
69+
TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true);
70+
}
71+
6772
@Test
6873
void testStructTypeWithArgumentsDuckDB() throws JSQLParserException {
6974
// @todo: check why the white-space after the "{" is needed?!

0 commit comments

Comments
 (0)