Ctrl+K
Logo image Logo image

Site Navigation

  • API Reference
  • Examples

Site Navigation

  • API Reference
  • Examples

Section Navigation

  • PyFlink Table
    • TableEnvironment
    • Table
    • Data Types
    • Window
    • Expressions
    • User Defined Functions
    • Descriptors
    • StatementSet
    • Catalog
  • PyFlink DataStream
  • PyFlink Common

pyflink.table.expressions.json_array#

json_array(on_null: pyflink.table.expression.JsonOnNull = JsonOnNull.ABSENT, *args) → pyflink.table.expression.Expression[source]#

Builds a JSON array string from a list of values.

This function returns a JSON string. The values can be arbitrary expressions. The on_null behavior defines how to treat NULL values.

Elements which are created from another JSON construction function call (json_object, json_array) are inserted directly rather than as a string. This allows building nested JSON structures.

Examples:

>>> json_array() # '[]'
>>> json_array(JsonOnNull.NULL, 1, "2") # '[1,"2"]'

>>> # Expressions as values
>>> json_array(JsonOnNull.NULL, col("orderId"))

>>> json_array(JsonOnNull.NULL, null_of(DataTypes.STRING()))   # '[null]'
>>> json_array(JsonOnNull.ABSENT, null_of(DataTypes.STRING())) # '[]'

>>> json_array(JsonOnNull.NULL, json_array(JsonOnNull.NULL, 1)) # '[[1]]'

See also

json_object()

New in version 1.12.0.

previous

pyflink.table.expressions.json_object_agg

next

pyflink.table.expressions.json_array_agg

Show Source

Created using Sphinx 4.5.0.