hotfix for huge countries
Browse files
climateqa/engine/talk_to_data/ipcc/queries.py
CHANGED
|
@@ -2,6 +2,7 @@ from typing import TypedDict, Optional
|
|
| 2 |
|
| 3 |
from climateqa.engine.talk_to_data.ipcc.config import HUGE_MACRO_COUNTRIES, MACRO_COUNTRIES
|
| 4 |
from climateqa.engine.talk_to_data.config import IPCC_DATASET_URL
|
|
|
|
| 5 |
class IndicatorPerYearAtLocationQueryParams(TypedDict, total=False):
|
| 6 |
"""
|
| 7 |
Parameters for querying the evolution of an indicator per year at a specific location.
|
|
@@ -53,10 +54,10 @@ def indicator_per_year_at_location_query(
|
|
| 53 |
elif country_code in HUGE_MACRO_COUNTRIES:
|
| 54 |
table_path = f"'{IPCC_DATASET_URL}/{table.lower()}/{country_code}_macro.parquet'"
|
| 55 |
sql_query = f"""
|
| 56 |
-
SELECT year, scenario, {indicator_column}
|
| 57 |
FROM {table_path}
|
| 58 |
WHERE latitude = {latitude} AND longitude = {longitude} AND year >= 1950
|
| 59 |
-
ORDER year, scenario
|
| 60 |
"""
|
| 61 |
else:
|
| 62 |
table_path = f"'{IPCC_DATASET_URL}/{table.lower()}/{country_code}.parquet'"
|
|
@@ -120,7 +121,7 @@ def indicator_for_given_year_query(
|
|
| 120 |
elif country_code in HUGE_MACRO_COUNTRIES:
|
| 121 |
table_path = f"'{IPCC_DATASET_URL}/{table.lower()}/{country_code}_macro.parquet'"
|
| 122 |
sql_query = f"""
|
| 123 |
-
SELECT latitude, longitude, scenario, {indicator_column}
|
| 124 |
FROM {table_path}
|
| 125 |
WHERE year = {year}
|
| 126 |
ORDER BY latitude, longitude, scenario
|
|
|
|
| 2 |
|
| 3 |
from climateqa.engine.talk_to_data.ipcc.config import HUGE_MACRO_COUNTRIES, MACRO_COUNTRIES
|
| 4 |
from climateqa.engine.talk_to_data.config import IPCC_DATASET_URL
|
| 5 |
+
|
| 6 |
class IndicatorPerYearAtLocationQueryParams(TypedDict, total=False):
|
| 7 |
"""
|
| 8 |
Parameters for querying the evolution of an indicator per year at a specific location.
|
|
|
|
| 54 |
elif country_code in HUGE_MACRO_COUNTRIES:
|
| 55 |
table_path = f"'{IPCC_DATASET_URL}/{table.lower()}/{country_code}_macro.parquet'"
|
| 56 |
sql_query = f"""
|
| 57 |
+
SELECT year, scenario, {indicator_column}
|
| 58 |
FROM {table_path}
|
| 59 |
WHERE latitude = {latitude} AND longitude = {longitude} AND year >= 1950
|
| 60 |
+
ORDER BY year, scenario
|
| 61 |
"""
|
| 62 |
else:
|
| 63 |
table_path = f"'{IPCC_DATASET_URL}/{table.lower()}/{country_code}.parquet'"
|
|
|
|
| 121 |
elif country_code in HUGE_MACRO_COUNTRIES:
|
| 122 |
table_path = f"'{IPCC_DATASET_URL}/{table.lower()}/{country_code}_macro.parquet'"
|
| 123 |
sql_query = f"""
|
| 124 |
+
SELECT latitude, longitude, scenario, {indicator_column}
|
| 125 |
FROM {table_path}
|
| 126 |
WHERE year = {year}
|
| 127 |
ORDER BY latitude, longitude, scenario
|