harshmotw-db commented on code in PR #49487:
URL: https://github.com/apache/spark/pull/49487#discussion_r1915815053
##########
python/pyspark/sql/connect/conversion.py:
##########
@@ -303,8 +307,11 @@ def convert_variant(value: Any) -> Any:
isinstance(value, dict)
and all(key in value for key in ["value", "metadata"])
and all(isinstance(value[key], bytes) for key in ["value",
"metadata"])
+ and not variants_as_dicts
):
return VariantVal(value["value"], value["metadata"])
+ elif isinstance(value, VariantVal) and variants_as_dicts:
Review Comment:
Good Question. For now, we should throw an error in the other cases as I am
not aware of any code paths we can use to test them. I specifically set
`variants_as_dicts` to false in one particular case which was encountered
during `createDataFrame`.
To be more specific:
- `value` is `VariantVal` & `variants_as_dicts` is `False`: This was not
handled before (`value` is `VariantVal` was not handled at all) and is still
not handled => no regression.
- `value` is `dict` & `variants_as_dicts` is `True`: `variants_as_dicts` is
`True` is only possible in one codepath - the one where I have set
`variants_as_dicts` to true. Earlier, this would have returned Variants and we
would see an error later on anyway (in pa.Table.from_arrays). I don't think
this can cause any regressions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]