Method for Mapping Redshift Query Results to Structs #2367
MichaelBonnet
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have found mapping Redshift Data service query results to be quite difficult to work with. Mapping records from the
*redshiftdata.GetStatementResultOutput
to a struct - something quite common in Go DB operations - is horrendously complicated.For example, say I have two tables in Redshift, which are analogous to two structs modeling those tables:
Because of a lack of an easy way to map the results of a query to a struct or even get a JSON representation of it, I have to write some overly verbose code, and have bespoke methods for each struct:
Conversion/extraction helpers, bespoke functions, and magic numbers, oh my. One can only imagine the headache for a table with 50+ columns or changing the order/number of columns.
I ask for either pointers to how to do this better/in a less verbose way, or for a built-in function that either lets one map results to a slice of structs or at least generates JSON for it.
Beta Was this translation helpful? Give feedback.
All reactions