Skip to content

Instantly share code, notes, and snippets.

@patrikbraborec
Created October 26, 2022 08:46
Show Gist options
  • Save patrikbraborec/88d9f295227543fcc35debeac1ea9500 to your computer and use it in GitHub Desktop.
Save patrikbraborec/88d9f295227543fcc35debeac1ea9500 to your computer and use it in GitHub Desktop.
with stock as (
select id, symbol, date, to_json(data) as data_json from input_stage.stock
),
final as (
select
id,
symbol,
date,
CAST(json_extract_path_text(data_json, '1. open') as float) as open,
CAST(json_extract_path_text(data_json, '2. high') as float) as high,
CAST(json_extract_path_text(data_json, '3. low') as float) as low,
CAST(json_extract_path_text(data_json, '4. close') as float) as close,
CAST(json_extract_path_text(data_json, '5. volume') as float) as volume
from stock
)
select * from final
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment