@@ -152,17 +152,86 @@ func TestCoalesce(t *testing.T) {
152152 typ : types .Float64 ,
153153 nullable : false ,
154154 },
155+ {
156+ name : "coalesce(sysInt, sysInt)" ,
157+ input : []sql.Expression {
158+ expression .NewLiteral (1 , types .NewSystemIntType ("int1" , 0 , 10 , false )),
159+ expression .NewLiteral (2 , types .NewSystemIntType ("int2" , 0 , 10 , false )),
160+ },
161+ expected : 1 ,
162+ typ : types .Int64 ,
163+ nullable : false ,
164+ },
165+ {
166+ name : "coalesce(sysInt, sysUint)" ,
167+ input : []sql.Expression {
168+ expression .NewLiteral (1 , types .NewSystemIntType ("int1" , 0 , 10 , false )),
169+ expression .NewLiteral (2 , types .NewSystemUintType ("int2" , 0 , 10 )),
170+ },
171+ expected : 1 ,
172+ typ : types .MustCreateDecimalType (20 , 0 ),
173+ nullable : false ,
174+ },
175+ {
176+ name : "coalesce(sysUint, sysUint)" ,
177+ input : []sql.Expression {
178+ expression .NewLiteral (1 , types .NewSystemUintType ("int1" , 0 , 10 )),
179+ expression .NewLiteral (2 , types .NewSystemUintType ("int2" , 0 , 10 )),
180+ },
181+ expected : 1 ,
182+ typ : types .Uint64 ,
183+ nullable : false ,
184+ },
185+ {
186+ name : "coalesce(sysDouble, sysDouble)" ,
187+ input : []sql.Expression {
188+ expression .NewLiteral (1.0 , types .NewSystemDoubleType ("dbl1" , 0.0 , 10.0 )),
189+ expression .NewLiteral (2.0 , types .NewSystemDoubleType ("dbl2" , 0.0 , 10.0 )),
190+ },
191+ expected : 1.0 ,
192+ typ : types .Float64 ,
193+ nullable : false ,
194+ },
195+ {
196+ name : "coalesce(sysText)" ,
197+ input : []sql.Expression {
198+ expression .NewLiteral ("abc" , types .NewSystemStringType ("str1" )),
199+ },
200+ expected : "abc" ,
201+ typ : types .LongText ,
202+ nullable : false ,
203+ },
204+ {
205+ name : "coalesce(sysEnum)" ,
206+ input : []sql.Expression {
207+ expression .NewLiteral ("abc" , types .NewSystemEnumType ("str1" )),
208+ },
209+ expected : "abc" ,
210+ typ : types.EnumType {},
211+ nullable : false ,
212+ },
213+ {
214+ name : "coalesce(sysSet)" ,
215+ input : []sql.Expression {
216+ expression .NewLiteral ("abc" , types .NewSystemSetType ("str1" , "abc" )),
217+ },
218+ expected : "abc" ,
219+ typ : types .MustCreateSetType ([]string {"abc" }, sql .Collation_Default ),
220+ nullable : false ,
221+ },
155222 }
156223
157224 for _ , tt := range testCases {
158- c , err := NewCoalesce (tt .input ... )
159- require .NoError (t , err )
225+ t .Run (tt .name , func (t * testing.T ) {
226+ c , err := NewCoalesce (tt .input ... )
227+ require .NoError (t , err )
160228
161- require .Equal (t , tt .typ , c .Type ())
162- require .Equal (t , tt .nullable , c .IsNullable ())
163- v , err := c .Eval (sql .NewEmptyContext (), nil )
164- require .NoError (t , err )
165- require .Equal (t , tt .expected , v )
229+ require .Equal (t , tt .typ , c .Type ())
230+ require .Equal (t , tt .nullable , c .IsNullable ())
231+ v , err := c .Eval (sql .NewEmptyContext (), nil )
232+ require .NoError (t , err )
233+ require .Equal (t , tt .expected , v )
234+ })
166235 }
167236}
168237
0 commit comments