diff --git a/docs/sql-ref-functions-builtin-jsonFunctions.md b/docs/sql-ref-functions-builtin-jsonFunctions.md new file mode 100644 index 0000000000000..a8332dcd81ed6 --- /dev/null +++ b/docs/sql-ref-functions-builtin-jsonFunctions.md @@ -0,0 +1,211 @@ +--- +layout: global +title: Built-in JSON Functions +displayTitle: Built-in JSON Functions +license: | + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--- + +JSON functions are used for operating on JSON strings. Table lists all the JSON function supported +by Spark. + +
| Function | Arguments | Description |
|---|---|---|
| get_json_object(json, path) | +a JSON string; JSON path | +Extracts json object from a json string based on json path specified, and returns json + string of the extracted json object. It will return null if the input json string is invalid. + | +
| json_tuple(json, fields*) | +a JSON string; field names as string | +Creates a new row for a json column according to the given field names. At least one field + name must be given. | +
| from_json(expression, schema, options) | +expression contains a JSON string; schema to use when parsing the JSON string; options to + to control how JSON is parsed | +Parses an expression containing a JSON string into a `MapType` with `StringType` as keys + type, `StructType` or `ArrayType` of `StructType`s with the specified schema. Returns + `null`, in the case of an unparseable string. | +
| to_json(expression, options) | +expression contains a struct, an array or a map; options to control how the struct column + is converted into a json string. | +Converts a column containing a `StructType`, `ArrayType` or a `MapType` into a JSON + string with the specified schema. Throws an exception, in the case of an unsupported + type. The function supports the `pretty` option which enables pretty JSON generation. + | +
| schema_of_json(json, options) | +JSON string; options to control how JSON is parsed | +Parses a JSON string and infers its schema in DDL format using options. | +