使用 JSON_PARSE 將資料插入 SUPER 欄 - Amazon Redshift

Amazon Redshift 將不再支援從修補程式 198 開始建立新的 Python UDFs。現有 Python UDF 將繼續正常運作至 2026 年 6 月 30 日。如需詳細資訊,請參閱部落格文章

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

使用 JSON_PARSE 將資料插入 SUPER 欄

您可以使用 JSON_PARSE 函數 將 JSON 資料插入或更新到 SUPER 欄中。該函數剖析 JSON 格式的資料,並將其轉換為 SUPER 資料類型,您可以在 INSERT 或 UPDATE 陳述式中使用。

下列範例將 JSON 資料插入到 SUPER 欄。如果查詢中缺少 JSON_PARSE 函式,Amazon Redshift 會將該值視為單一字串,而不是必須剖析的 JSON 格式字串。

--Drop the table if it exists. DROP TABLE IF EXISTS test_json; --Create the table. CREATE TABLE test_json (all_data SUPER); --Populate the table. INSERT INTO test_json VALUES (JSON_PARSE(' { "name": { "first_name": "Jake", "last_name": "Smith" }, "age": 30, "hobby": "Biking" }' ) ); SELECT * FROM test_json; all_data --------- {"name":{"first_name":"Jake","last_name":"Smith"},"age":30,"hobby":"Biking"}