Advertisement
gubichas

weather4

Dec 17th, 2023
830
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. insert into kdz17.staging_weather_facts
  2. select distinct
  3.    icao_code,
  4.    TO_TIMESTAMP(local_datetime, 'DD.MM.YYYY HH24:MI'),
  5.    t_air_temperature,
  6.    p0_sea_lvl,
  7.    p_station_lvl,
  8.    u_humidity,
  9.    dd_wind_direction,
  10.    ff_wind_speed,
  11.    ff10_max_gust_value,
  12.    ww_present,
  13.    ww_recent,
  14.    c_total_clouds,
  15.    vv_horizontal_visibility,
  16.    td_temperature_dewpoint,
  17.    loaded_ts
  18. from kdz17.etl_load_weather_facts_01
  19. on conflict (icao_code, local_datetime) do update
  20. set
  21.    t_air_temperature = excluded.t_air_temperature,
  22.    p0_sea_lvl = excluded.p0_sea_lvl,
  23.    p_station_lvl = excluded.p_station_lvl,
  24.    u_humidity = excluded.u_humidity,
  25.    dd_wind_direction = excluded.dd_wind_direction,
  26.    ff_wind_speed = excluded.ff_wind_speed,
  27.    ff10_max_gust_value = excluded.ff10_max_gust_value,
  28.    ww_present = excluded.ww_present,
  29.    ww_recent = excluded.ww_recent,
  30.    c_total_clouds = excluded.c_total_clouds,
  31.    vv_horizontal_visibility = excluded.vv_horizontal_visibility,
  32.    td_temperature_dewpoint = excluded.td_temperature_dewpoint,
  33.    loaded_ts = now();
  34.   delete from kdz17.etl_weather_facts
  35. where exists (select 1 from kdz17.etl_weather_facts);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement