[go: up one dir, main page]

0% found this document useful (0 votes)
5 views1 page

Handling Nested Data (JSON 3)

The document contains SQL queries for extracting and manipulating nested data from a JSON file in a database. It demonstrates how to select specific fields, handle arrays, and perform unions on the data. The queries focus on retrieving job-related information and previous company details from the JSON structure.

Uploaded by

techgeek0069
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Handling Nested Data (JSON 3)

The document contains SQL queries for extracting and manipulating nested data from a JSON file in a database. It demonstrates how to select specific fields, handle arrays, and perform unions on the data. The queries focus on retrieving job-related information and previous company details from the JSON structure.

Uploaded by

techgeek0069
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

// Handling nested data

SELECT RAW_FILE:job as job FROM OUR_FIRST_DB.PUBLIC.JSON_RAW;

SELECT
RAW_FILE:job.salary::INT as salary
FROM OUR_FIRST_DB.PUBLIC.JSON_RAW;

SELECT
RAW_FILE:first_name::STRING as first_name,
RAW_FILE:job.salary::INT as salary,
RAW_FILE:job.title::STRING as title
FROM OUR_FIRST_DB.PUBLIC.JSON_RAW;

// Handling arreys

SELECT
RAW_FILE:prev_company as prev_company
FROM OUR_FIRST_DB.PUBLIC.JSON_RAW;

SELECT
RAW_FILE:prev_company[1]::STRING as prev_company
FROM OUR_FIRST_DB.PUBLIC.JSON_RAW;

SELECT
ARRAY_SIZE(RAW_FILE:prev_company) as prev_company
FROM OUR_FIRST_DB.PUBLIC.JSON_RAW;

SELECT
RAW_FILE:id::int as id,
RAW_FILE:first_name::STRING as first_name,
RAW_FILE:prev_company[0]::STRING as prev_company
FROM OUR_FIRST_DB.PUBLIC.JSON_RAW
UNION ALL
SELECT
RAW_FILE:id::int as id,
RAW_FILE:first_name::STRING as first_name,
RAW_FILE:prev_company[1]::STRING as prev_company
FROM OUR_FIRST_DB.PUBLIC.JSON_RAW
ORDER BY id

You might also like