Skip to content

Commit

Permalink
Merge pull request #117 from nrccua/DS-460-fix-bug-in-read_constants_…
Browse files Browse the repository at this point in the history
…from_db

Fix bug with sql statement in function read_constants_from_db
  • Loading branch information
nrccua-timr authored Dec 1, 2023
2 parents 169800d + ab76b4f commit e23346a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ History
=======


v0.20.4 (2023-12-01)

* Fix bug with sql statement in function ds_utils.read_constants_from_db.
* Update aiojobs==1.2.1.
* Update polars==0.19.18.


v0.20.3 (2023-11-29)

* Add Databricks functions to read/write constants for Data Science to use across projects.
Expand Down
4 changes: 2 additions & 2 deletions aioradio/ds_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ def read_constants_from_db(constants_list=None):
"""Read all constants or pass in a list to filter constants."""

table = f"{db_catalog('prod')}.student_data.constants"
constants = '*' if constants_list is None else ','.join(constants_list)
mapping = {i['key']: json.loads(i['value']) for i in sql_to_polars_df(f'SELECT {constants} FROM {table}').to_dicts()}
where_clause = f'WHERE key in ({str(constants_list)[1:-1]})' if constants_list is not None else ''
mapping = {i['key']: json.loads(i['value']) for i in sql_to_polars_df(f'SELECT * FROM {table} {where_clause}').to_dicts()}

return mapping

Expand Down
4 changes: 2 additions & 2 deletions aioradio/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
aioboto3==11.3.1
aiojobs==1.2.0
aiojobs==1.2.1
backoff==2.2.1
boto3==1.28.17
botocore==1.31.17
Expand All @@ -17,7 +17,7 @@ moto==3.1.18
openpyxl==3.0.10
orjson==3.8.10
pandas==2.1.3
polars==0.19.17
polars==0.19.18
pre-commit==3.5.0
psycopg2-binary==2.9.9
pyarrow==13.0.0
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
long_description = fileobj.read()

setup(name='aioradio',
version='0.20.3',
version='0.20.4',
description='Generic asynchronous i/o python utilities for AWS services (SQS, S3, DynamoDB, Secrets Manager), Redis, MSSQL (pyodbc), JIRA and more',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit e23346a

Please sign in to comment.