What is a foldable column?

Viewed 308

One of the variants of schema_of_json accepts a column containing a JSON String. The documentation of the parameter says that the column must be

a foldable string column containing a JSON string.

scaladoc

What is the exact meaning of foldable column in this context?

1 Answers

Based on document here:

Returns true when an expression is a candidate for static evaluation before the query is executed. The following conditions are used to determine suitability for constant folding:

  • A Coalesce is foldable if all of its children are foldable
  • A BinaryExpression is foldable if its both left and right child are foldable
  • A Not, IsNull, or IsNotNull is foldable if its child is foldable
  • A Literal is foldable
  • A Cast or UnaryMinus is foldable if its child is foldable
Related