示例数据: OpenWeatherMap – 已弃用¶
OpenWeatherMap (http://openweathermap.org/) 是一个 JSON 格式的近期历史和预报天气数据的存储库。Snowflake 导入这些天气数据,并将其免费提供给所有 Snowflake 账户,因此您可以使用真实世界的数据来试验我们独特的高性能半结构化列式功能。
重要
提供样本天气数据用于评估和测试目的。数据在 Snowflake 中定期更新,但不实时维护,这可能会导致更新偶尔失误(即我们不保证数据始终是最新的和/或无间隙的)。
因此,我们不建议在生产系统中使用这些数据。
本主题内容:
表¶
数据集包括以下表,所有表都以原生 JSON 格式存储并随时间累积:
表名称 |
描述 |
JSON 描述 |
---|---|---|
DAILY_14_TOTAL |
超过 20,000 个城市的 12 天每日天气预报。 |
点击 此处 (http://openweathermap.org/forecast16#JSON) |
DAILY_16_TOTAL |
超过 200,000 个城市的 12 天每日天气预报(更新频率较低)。 |
点击 此处 (http://openweathermap.org/forecast16#JSON) |
HOURLY_14_TOTAL |
超过 20,000 个城市的 4 天每小时天气预报。 |
点击 此处 (http://openweathermap.org/forecast5#JSON) |
HOURLY_16_TOTAL |
超过 200,000 个城市的 4 天每小时天气预报(更新频率较低)。 |
点击 此处 (http://openweathermap.org/forecast5#JSON) |
WEATHER_14_TOTAL |
20,000 个城市的最新天气。 |
点击 此处 (http://openweathermap.org/current#current_JSON) |
查询示例¶
以下查询检索纽约市最近的高温和低温读数,从摄氏度转换为华氏温度,以及读数的纬度和经度:
select (V:main.temp_max - 273.15) * 1.8000 + 32.00 as temp_max_far, (V:main.temp_min - 273.15) * 1.8000 + 32.00 as temp_min_far, cast(V:time as TIMESTAMP) time, V:city.coord.lat lat, V:city.coord.lon lon, V from snowflake_sample_data.weather.WEATHER_14_TOTAL where v:city.name = 'New York' and v:city.country = 'US' order by time desc limit 10;
以下查询将天气预报与实际天气读数进行比较:
with forecast as (select ow.V:time as prediction_dt, ow.V:city.name as city, ow.V:city.country as country, cast(f.value:dt as timestamp) as forecast_dt, f.value:temp.max as forecast_max_k, f.value:temp.min as forecast_min_k, f.value as forecast from snowflake_sample_data.weather.daily_16_total ow, lateral FLATTEN(input => V, path => 'data') f), actual as (select V:main.temp_max as temp_max_k, V:main.temp_min as temp_min_k, cast(V:time as timestamp) as time_dt, V:city.name as city, V:city.country as country from snowflake_sample_data.weather.WEATHER_14_TOTAL) select cast(forecast.prediction_dt as timestamp) prediction_dt, forecast.forecast_dt, forecast.forecast_max_k, forecast.forecast_min_k, actual.temp_max_k, actual.temp_min_k from actual left join forecast on actual.city = forecast.city and actual.country = forecast.country and date_trunc(day, actual.time_dt) = date_trunc(day, forecast.forecast_dt) where actual.city = 'New York' and actual.country = 'US' order by forecast_dt desc, prediction_dt desc;