Add standard Ruby collection methods to Result and Row#159
Open
wpfleger96 wants to merge 2 commits intorinsed-org:masterfrom
Open
Add standard Ruby collection methods to Result and Row#159wpfleger96 wants to merge 2 commits intorinsed-org:masterfrom
wpfleger96 wants to merge 2 commits intorinsed-org:masterfrom
Conversation
- Add Result#empty? for checking empty result sets - Add Row#dig for safe nested value access (useful for VARIANT/JSON columns) - Add Row#to_h for explicit hash conversion - Add Row#key?/has_key? for column existence checks - Add Row#fetch for access with default values or error handling - Add unit tests (28 test cases, no Snowflake required) Addresses missing methods discovered during BigQuery to Snowflake migration.
1b44870 to
2080bb5
Compare
Contributor
|
Thanks @wpfleger96 - I'll try to steal some time and take a look through this in the next week or so, much appreciated! |
Author
|
@reidnimz 😅 I think the tests are failing bc GH Actions is blocking secrets since I opened this PR from a fork |
reidnimz
requested changes
Jan 20, 2026
Contributor
reidnimz
left a comment
There was a problem hiding this comment.
Good addition, thanks @wpfleger96! Just a couple of minor things.
You're right, I forgot with the secrets, it's not going to work on a branch. But, I'll run it locally quick before confirming and then I'll try and get a release out today or tomorrow.
1. removed custom unnecessary to_h method implementation (and update CHANGELOG accordingly) 2. Add happy path test for Row#fetch 3. Added test cases for Row#key? since it's part of the API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds standard Ruby collection methods for query results:
empty?,dig,key?, andfetch. A recent BigQuery to Snowflake migration revealed these methods were missing;ResultincludesEnumerablebut lacksempty?, whileRowhas[]access but no safe nested access or column existence checks.Implementation:
Result#empty?to check if result set has no rowsRow#digfor safe nested value access (useful for VARIANT/JSON columns)Row#key?/has_key?to check column existenceRow#fetchwith default values and block support