MetricSign
EN|NLRequest Access
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

  1. 1Cast BINARY columns to STRING with base64 encoding before passing to to_json: base64(binary_col).
  2. 2Ensure the input to from_json is always a STRING column, not a pre-parsed struct.
  3. 3Use get_json_object for single-field extraction from JSON strings instead of full schema parsing.
  4. 4Inspect column types with DESCRIBE or printSchema() before applying JSON functions.
  5. 5For TIMESTAMP handling, convert to Unix epoch (unix_timestamp) before JSON serialization.

Frequently asked questions

Can I use to_json on an entire row?

Yes — to_json(struct(*)) serializes all columns of a row as a JSON object. However any column with an unsupported type will still raise INVALID_JSON_DATA_TYPE.

Does this error occur in Delta Live Tables?

Yes. DLT pipelines that use SQL or PySpark with JSON functions are subject to the same type restrictions.

Other data quality errors