-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional parsing of query result into objects #78
Optional parsing of query result into objects #78
Conversation
merge for source
Codecov Report
@@ Coverage Diff @@
## master #78 +/- ##
==========================================
+ Coverage 74.65% 75.25% +0.59%
==========================================
Files 7 7
Lines 363 396 +33
Branches 48 54 +6
==========================================
+ Hits 271 298 +27
- Misses 77 80 +3
- Partials 15 18 +3
Continue to review full report at Codecov.
|
@harlev Thanks a lot. It's a very useful feature. error message from TravisCI: https://travis-ci.org/github/bryanyang0528/ksql-python/jobs/720870491 |
@bryanyang0528 I have marked the failing test to be skipped. Same as the other tests of the same type, which are using streaming queries. |
@harlev Thanks for the great contribution. |
The current behavior of a query is to return a generator, which yields first the header with the schema, then each row of the results, all as strings without the field names.
This optional addition, keeps this behavior, but adds an optional flag to get each row of the result as a dictionary structured based on the schema.
The user of the
Query
API can optionally providereturn_objects=True
as parameter to enable this new functionality.This change should not break any existing behavior.
A good example for the new functionality is in the test test_ksql_parse_query_result
The schema here includes basic fields (INT, STRING etc) and the structured options of STRUCT, MAP & ARRAY.
In this test the events sent to the topic contain
The default results would be (without the new
return_objects
flag) a header stringAnd then the default row of result string would be
With this new update the result will be a more usefull dictionary with the actual field names
A second test test_ksql_parse_query_result_with_utils shows how the same functionality could be achieved by using the new utility functions directly on the query results to perform the parsing.