2222 Field ,
2323 ValidationError ,
2424 model_validator ,
25+ SerializerFunctionWrapHandler ,
26+ WrapSerializer ,
2527)
2628from typing import (
2729 Annotated ,
@@ -124,12 +126,18 @@ def check_metric_type(self) -> Self:
124126 return self
125127
126128
129+ def serialize_comma_string (input : Any , handler : SerializerFunctionWrapHandler ) -> str | None :
130+ if val := handler (input ):
131+ return "," .join (val )
132+ return None
133+
134+
127135class QueryParams (BaseModel ):
128136 dataset : str
129- groupBy : list [FieldName ] | None = None
137+ groupBy : Annotated [ list [FieldName ] | None , WrapSerializer ( serialize_comma_string )] = None
130138 aggregator : Aggregator | None = None
131- fields : list [FieldName ] | None = None
132- orderBy : list [str ] | None = (
139+ fields : Annotated [ list [FieldName ] | None , WrapSerializer ( serialize_comma_string )] = None
140+ orderBy : Annotated [ list [str ] | None , WrapSerializer ( serialize_comma_string )] = (
133141 None # More complex than just FieldName, can be prefixed with - to invert sort
134142 )
135143 dataType : DataType | None = None
@@ -153,7 +161,7 @@ def check_datatype_needed(self) -> Self:
153161 return self
154162
155163 def to_dict (self ) -> dict [str , Any ]:
156- return self .model_dump (exclude_none = True , by_alias = True )
164+ return self .model_dump (exclude_none = True , by_alias = True , mode = 'json' )
157165
158166
159167class ChunkedParams (BaseModel ):
0 commit comments