Medium severitydata quality
Power BI Refresh Error:
INVALID_JSON_DATA_TYPE
What does this error mean?
A JSON function received a column or expression with a data type that is not supported for JSON serialization or deserialization. Databricks raises this error when to_json, from_json, or schema_of_json is applied to an unsupported type such as a binary or user-defined type.
Common causes
- 1to_json called on a column of type BINARY, which cannot be serialized to a JSON string
- 2from_json applied to a column that contains non-string data such as ARRAY or MAP
- 3A UDF returns a custom type that is not JSON-serializable
- 4schema_of_json used on a non-literal expression instead of a sample string
- 5A Delta table column has type TIMESTAMP WITH LOCAL TIME ZONE, which some JSON functions do not support
How to fix it
- 1Cast BINARY columns to STRING with base64 encoding before passing to to_json: base64(binary_col).
- 2Ensure the input to from_json is always a STRING column, not a pre-parsed struct.
- 3Use get_json_object for single-field extraction from JSON strings instead of full schema parsing.
- 4Inspect column types with DESCRIBE or printSchema() before applying JSON functions.
- 5For TIMESTAMP handling, convert to Unix epoch (unix_timestamp) before JSON serialization.