@@ -210,28 +210,44 @@ public object DuckDb : DbType("duckdb") {
210210 MAP -> {
211211 val (key, value) = parseMapTypes(sqlTypeName)
212212
213+ val parsedKeyType = parseDuckDbType(key, false )
214+ val parsedValueType =
215+ parseDuckDbType(value, true ).cast<Any ?, Any ?, Any ?>()
216+
213217 val targetMapType = Map ::class .createType(
214218 listOf (
215- KTypeProjection .invariant(parseDuckDbType(key, false ) .targetSchema.type),
216- KTypeProjection .invariant(parseDuckDbType(value, true ) .targetSchema.type),
219+ KTypeProjection .invariant(parsedKeyType .targetSchema.type),
220+ KTypeProjection .invariant(parsedValueType .targetSchema.type),
217221 ),
218222 )
219223
220- dbColumnTypeInformation<Map <String , Any ?>>(ColumnSchema .Value (targetMapType))
224+ dbColumnTypeInformationWithPreprocessing<Map <String , Any ?>, Map <String , Any ?>>(
225+ ColumnSchema .Value (targetMapType),
226+ ) { map, _ ->
227+ // only need to preprocess the values, as the keys are just Strings
228+ map?.mapValues { (_, value) ->
229+ parsedValueType.preprocess(value)
230+ }
231+ }
221232 }
222233
223234 LIST , ARRAY -> {
224235 // TODO requires #1266 and #1273 for specific types
225236 val listType = parseListType(sqlTypeName)
226- val parsedListType = parseDuckDbType(listType, true )
237+ val parsedListType =
238+ parseDuckDbType(listType, true ).cast<Any ?, Any ?, Any ?>()
239+
227240 val targetListType = List ::class .createType(
228241 listOf (KTypeProjection .invariant(parsedListType.targetSchema.type)),
229242 )
243+
230244 // todo maybe List<DataRow> should become FrameColumn
231245 dbColumnTypeInformationWithPreprocessing<SqlArray , List <Any ?>>(
232246 ColumnSchema .Value (targetListType),
233- ) { it, typeInfo ->
234- it?.toList()
247+ ) { array, _ ->
248+ array
249+ ?.toList()
250+ ?.map(parsedListType::preprocess) // recursively preprocess
235251 }
236252 }
237253
0 commit comments