Using structured fields with PyAthena
See original GitHub issueI’m trying to query a table that has columns with struct fields in the following format:
{quantity=1, price=0.1, valid_data=2022-xx-xx 08:42:10.2431}
I can execute simple queries using the sub-fields inside these structures, but I would like to use ORM. However, I can’t seem to find a way to map struct fields and these seem to be simply interpreted as a string “{quantity… }”
Is there currently a way to use PyAthena along with SQLAlchemy ORM to map these fields?
Thanks!
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Querying arrays with complex types and nested structures
Examples in this section show how to change element's data type, locate elements within arrays, and find keywords using Athena queries.
Read more >C-like structures in Python - Stack Overflow
You can access the fields of a class using a dictionary because the fields of a class, its methods and all its properties...
Read more >Working with complex types | The Athena Guide
Fields in nested structs are accessed the same way, just like how you would access properties in a JavaScript object.
Read more >Data Science with Python Pandas by Athena Kan - YouTube
Harvard Business Review named data scientist "the sexiest job of the 21st century." Python pandas is a commonly-used tool in the industry to ......
Read more >PyAthena - PyPI
You can use pandas.DataFrame.to_sql to write records stored in DataFrame to Amazon Athena. pandas.DataFrame.to_sql uses SQLAlchemy, so you need to install it.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can register an issue in the python-bigquery-sqlalchemy repository. https://github.com/googleapis/python-bigquery-sqlalchemy/issues
Currently, struct type is not supported. Maybe python-bigquery-sqlalchemy’s handling of the STRUCT type would be helpful for implementation. https://github.com/googleapis/python-bigquery-sqlalchemy/blob/main/sqlalchemy_bigquery/_struct.py#L46