File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
crates/polars-json/src/json/write Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -491,6 +491,20 @@ pub(crate) fn new_serializer<'a>(
491
491
list_serializer :: < i64 > ( array. as_any ( ) . downcast_ref ( ) . unwrap ( ) , offset, take)
492
492
} ,
493
493
ArrowDataType :: Dictionary ( k, v, _) => match ( k, & * * v) {
494
+ ( IntegerType :: UInt8 , ArrowDataType :: Utf8View ) => {
495
+ let array = array
496
+ . as_any ( )
497
+ . downcast_ref :: < DictionaryArray < u8 > > ( )
498
+ . unwrap ( ) ;
499
+ dictionary_utf8view_serializer :: < u8 > ( array, offset, take)
500
+ } ,
501
+ ( IntegerType :: UInt16 , ArrowDataType :: Utf8View ) => {
502
+ let array = array
503
+ . as_any ( )
504
+ . downcast_ref :: < DictionaryArray < u16 > > ( )
505
+ . unwrap ( ) ;
506
+ dictionary_utf8view_serializer :: < u16 > ( array, offset, take)
507
+ } ,
494
508
( IntegerType :: UInt32 , ArrowDataType :: Utf8View ) => {
495
509
let array = array
496
510
. as_any ( )
Original file line number Diff line number Diff line change 20
20
21
21
import polars as pl
22
22
from polars .exceptions import ComputeError
23
- from polars .testing import assert_frame_equal
23
+ from polars .testing import assert_frame_equal , assert_series_equal
24
24
25
25
26
26
def test_write_json () -> None :
@@ -632,3 +632,11 @@ def test_ndjson_22229() -> None:
632
632
]
633
633
634
634
assert pl .read_ndjson (io .StringIO ("\n " .join (li ))).to_dict (as_series = False )
635
+
636
+
637
+ def test_json_encode_enum_23826 () -> None :
638
+ s = pl .Series ("a" , ["b" ], dtype = pl .Enum (["b" ]))
639
+ assert_series_equal (
640
+ s .to_frame ().select (c = pl .struct ("a" ).struct .json_encode ()).to_series (),
641
+ pl .Series ("c" , ['{"a":"0"}' ], pl .String ),
642
+ )
You can’t perform that action at this time.
0 commit comments