@@ -121,6 +121,35 @@ describe('BigQueryFormatter', () => {
121121 ` ) ;
122122 } ) ;
123123
124+ // Issue #279
125+ it ( 'supports parametric STRUCT with named fields' , ( ) => {
126+ expect ( format ( 'SELECT STRUCT<y INT64, z STRING>(1,"foo"), STRUCT<arr ARRAY<INT64>>([1,2,3]);' ) )
127+ . toBe ( dedent `
128+ SELECT
129+ STRUCT<y INT64, z STRING>(1, "foo"),
130+ STRUCT<arr ARRAY<INT64>>([1, 2, 3]);
131+ ` ) ;
132+ } ) ;
133+
134+ it ( 'supports uppercasing of STRUCT' , ( ) => {
135+ expect ( format ( 'select struct<Nr int64, myName string>(1,"foo");' , { keywordCase : 'upper' } ) )
136+ . toBe ( dedent `
137+ SELECT
138+ STRUCT<Nr INT64, myName STRING>(1, "foo");
139+ ` ) ;
140+ } ) ;
141+
142+ // XXX: This is hard to achieve with our current type-parameter processing hack.
143+ // At least we're preserving the case of identifier names here,
144+ // and lowercasing is luckily less used than uppercasing.
145+ it ( 'does not support lowercasing of STRUCT' , ( ) => {
146+ expect ( format ( 'SELECT STRUCT<Nr INT64, myName STRING>(1,"foo");' , { keywordCase : 'lower' } ) )
147+ . toBe ( dedent `
148+ select
149+ STRUCT<Nr INT64, myName STRING>(1, "foo");
150+ ` ) ;
151+ } ) ;
152+
124153 it ( 'supports parameterised types' , ( ) => {
125154 const result = format (
126155 `
0 commit comments