Last active
August 21, 2022 07:05
-
-
Save Gatsby-Lee/8dd469ec0f29188c3e43961ecd3e963d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Table schema with JSON output format | |
CREATE EXTERNAL TABLE `discover_cluster_tickets_dummy_json_v1`( | |
`cluster_id` string, | |
`created_date` timestamp | |
) | |
ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe' | |
STORED AS TEXTFILE | |
LOCATION 's3://aws-athena/my_db/dummy_json_v1/'; | |
-- INSERT stmt | |
INSERT INTO dummy_json_v1 (cluster_id, created_date) VALUES ('89f921dc', timestamp '2022-03-24 17:45:02.0'); | |
-- CREATE JSON output format data with CTAS | |
CREATE TABLE my_db.dummy_json_v1 | |
WITH ( | |
format = 'JSON', | |
external_location = 's3://aws-athena/my_db/dummy_json_v1' | |
) | |
AS SELECT * | |
FROM my_db.dummy_orc_v1; | |
-- expected content in file | |
{"cluster_id":"89f921dc","created_date":"2022-03-24 17:45:02.0"} | |
{"cluster_id":"a420cac4","created_date":"2022-07-21 21:13:28.0"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment