
Explanation:
The correct command is CREATE OR REPLACE TABLE parsed_events AS SELECT FROM_JSON(json_column, schema_of_json('')) AS struct_column FROM original_table; because it uses FROM_JSON with schema_of_json to convert the JSON strings into structs based on the schema inferred from an example JSON string, ensuring no null fields are present in the new table.
Ultimate access to all questions.
You have a column containing JSON strings that you wish to convert into structs. Which SQL command would you use to create a new table for storing these structs, ensuring no null fields are present, based on a schema derived from an example JSON string?
A
CREATE TABLE parsed_data AS SELECT FROM_JSON(json_column) AS struct_column FROM original_table;
B
CREATE TABLE parsed_data AS SELECT TO_STRUCT(json_column) FROM original_table;
C
CREATE OR REPLACE TABLE parsed_events AS SELECT FROM_JSON(json_column, schema_of_json('')) AS struct_column FROM original_table;
D
CREATE TABLE parsed_data AS SELECT CAST(json_column AS STRUCT) FROM original_table;
No comments yet.