@@ -149,8 +149,7 @@ SELECT cast(named_struct('a', named_struct('b', named_struct('c', 1, 'd', 'leaf'
149149query
150150SELECT cast(named_struct(' s1' , ' ' , ' s2' , ' ' , ' s3' , cast(null as string)) as string)
151151
152- -- Map-valued field: not supported, falls back to Spark.
153- query expect_fallback(to StringType is not supported)
152+ query
154153SELECT cast(named_struct(' m' , map(' k' , 1 )) as string)
155154
156155-- ----------------------------------------------------------------------------
@@ -270,69 +269,70 @@ SELECT cast(array(cast(1.5 as double), cast('NaN' as double), cast('-Infinity' a
270269query
271270SELECT cast(array(array(array(1 , 2 ), array(3 )), array(array(cast(null as int )))) as string)
272271
273- -- Array of map: not supported, falls back to Spark .
274- query expect_fallback(to StringType is not supported)
272+ -- Array of map: map-to-string is routed through the codegen dispatcher via the outer array .
273+ query
275274SELECT cast(array(map(' k' , 1 )) as string)
276275
277276-- ----------------------------------------------------------------------------
278277-- Map → string
279278-- ----------------------------------------------------------------------------
280- -- Comet does not implement map-to-string casts, so every map → string falls back to Spark.
279+ -- Comet has no native map-to-string cast; `CometCast` mixes in `CodegenDispatchFallback`, so
280+ -- these stay native via the codegen dispatcher and match Spark exactly.
281281-- Note: maps materialized through parquet have nondeterministic entry order, so map column
282282-- tests use literal maps directly rather than reading from a parquet table.
283283
284284-- Map with string keys, int values.
285- query expect_fallback(Cast from MapType)
285+ query
286286SELECT cast(map(' a' , 1 , ' b' , 2 , ' c' , 3 ) as string)
287287
288288-- Map with NULL values rendered as "null".
289- query expect_fallback(Cast from MapType)
289+ query
290290SELECT cast(map(' a' , 1 , ' b' , cast(null as int ), ' c' , 3 ) as string)
291291
292292-- Map with int keys, string values.
293- query expect_fallback(Cast from MapType)
293+ query
294294SELECT cast(map(1 , ' one' , 2 , ' two' , 3 , ' three' ) as string)
295295
296296-- Map with boolean values.
297- query expect_fallback(Cast from MapType)
297+ query
298298SELECT cast(map(' t' , true, ' f' , false, ' n' , cast(null as boolean )) as string)
299299
300300-- Map with bigint values at min/max.
301- query expect_fallback(Cast from MapType)
301+ query
302302SELECT cast(map(' max' , 9223372036854775807 , ' min' , - 9223372036854775808 , ' zero' , cast(0 as bigint )) as string)
303303
304304-- Map with decimal values.
305- query expect_fallback(Cast from MapType)
305+ query
306306SELECT cast(map(' pos' , cast(' 1.234567890123456789' as decimal (38 , 18 )), ' neg' , cast(' -1.234567890123456789' as decimal (38 , 18 )), ' null' , cast(null as decimal (38 , 18 ))) as string)
307307
308308-- Map with date and timestamp values.
309- query expect_fallback(Cast from MapType)
309+ query
310310SELECT cast(map(' a' , date ' 2024-01-15' , ' b' , date ' 1970-01-01' , ' c' , cast(null as date )) as string)
311311
312- query expect_fallback(Cast from MapType)
312+ query
313313SELECT cast(map(' a' , timestamp ' 2024-01-15 10:30:45' , ' b' , cast(null as timestamp )) as string)
314314
315315-- Map with binary values.
316- query expect_fallback(Cast from MapType)
316+ query
317317SELECT cast(map(' a' , X' 616263' , ' b' , X' ' , ' c' , cast(null as binary)) as string)
318318
319319-- Map with float / double values: NaN / ±0 / ±Infinity / NULL.
320- query expect_fallback(Cast from MapType)
320+ query
321321SELECT cast(map(' nan' , cast(' NaN' as float), ' neg0' , cast(- 0 .0 as float), ' null' , cast(null as float)) as string)
322322
323- query expect_fallback(Cast from MapType)
323+ query
324324SELECT cast(map(' nan' , cast(' NaN' as double), ' inf' , cast(' Infinity' as double), ' ninf' , cast(' -Infinity' as double), ' null' , cast(null as double)) as string)
325325
326326-- Map with struct values: each value rendered as `{f1, f2, ...}`.
327- query expect_fallback(Cast from MapType)
327+ query
328328SELECT cast(map(' a' , named_struct(' x' , 1 , ' y' , ' first' ), ' b' , cast(null as struct< x: int , y: string> )) as string)
329329
330330-- Map with array values.
331- query expect_fallback(Cast from MapType)
331+ query
332332SELECT cast(map(' a' , array(1 , 2 , 3 ), ' b' , array(cast(null as int )), ' c' , cast(null as array< int > )) as string)
333333
334334-- Empty map.
335- query expect_fallback(Cast from MapType)
335+ query
336336SELECT cast(map() as string)
337337
338338-- NULL map: Spark constant-folds this to a literal NULL, so the cast never reaches Comet
@@ -341,5 +341,5 @@ query
341341SELECT cast(cast(null as map< string, int > ) as string)
342342
343343-- Map of map.
344- query expect_fallback(Cast from MapType)
344+ query
345345SELECT cast(map(' outer' , map(' inner' , 1 )) as string)
0 commit comments