Skip to content
Prev Previous commit
Next Next commit
add examples
  • Loading branch information
dtenedor committed Jun 14, 2024
commit ac697415f94acc84a2880bc2cda69a1feab0f2ff
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ import org.apache.spark.util.Utils
usage = """
_FUNC_(child, jsonFormatSchema, options) - Converts a binary Avro value into a Catalyst value.
""",
examples = """
> SELECT IS_NULL(_FUNC_(result, '{"type": "record", "name": "struct", "fields": [{ "name": "u", "type": ["int","string"] }]}')) AS result FROM (SELECT NAMED_STRUCT('u', NAMED_STRUCT('member0', member0, 'member1', member1)) AS s FROM VALUES (1, NULL), (NULL, 'a') tab(member0, member1));
[false]
""",
note = """
The specified schema must match actual schema of the read data, otherwise the behavior
is undefined: it may fail or return arbitrary result.
Expand Down Expand Up @@ -121,6 +125,10 @@ case class FromAvroSqlFunction(child: Expression, jsonFormatSchema: Expression,
_FUNC_(child, jsonFormatSchema) - Converts a Catalyst binary input value into its corresponding
Avro format result.
""",
examples = """
> SELECT IS_NULL(_FUNC_(result, '{"type": "record", "name": "struct", "fields": [{ "name": "u", "type": ["int","string"] }]}', MAP() ).u FROM (SELECT FROM_AVRO(result, '{"type": "record", "name": "struct", "fields": [{ "name": "u", "type": ["int","string"] }]}' ) AS result FROM (SELECT NAMED_STRUCT('u', NAMED_STRUCT('member0', member0, 'member1', member1)) AS s FROM VALUES (1, NULL), (NULL, 'a') tab(member0, member1)));
[false]
""",
group = "misc_funcs",
since = "4.0.0"
)
Expand Down