-
Notifications
You must be signed in to change notification settings - Fork 69
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
Support type coercion for inconsistently represented properties #792
Comments
Note that type coercion can be achieved currently with |
This has been marked as stale because it is unassigned, and has not had recent activity. It will be closed after 21 days if no further activity occurs. If this should never go stale, please add the |
Still relevant IMO. |
I think the implementations I proposed here either overlap too much with schema logic or are a reinvention of stream maps. The best way forward for this kind of issue would be the ability to leverage stream maps as a developer, so closing as a duplicate of #1231. Feel free to reopen otherwise. |
Overview
It is possible for an API to return records that contain differently-typed, formatted or structured data. The SDK could provide a mechanism of property type coercion to solve this issue.
Example 1
Record A (string)
Record B (array of strings)
Example 2
Record A (string)
Record B (object containing string)
Example 3
Record A (string)
Record B (number)
Proposed Solution(s)
Define a callable mapping function, which is applied for specific properties whenever its argument type matches the property value type. This function should take the type
where
S
is the Source (argument) type andT
is the Target (return) type.Extension to Python-defined schema properties
Provide a callable function to keyword argument
coerce
forJsonTypeHelper
classes. The function return type can be inferred from the expected property schema (e.g.th.ArrayType(th.StringType)
would infer a return type ofList[str]
).Example implementations
RestStream
class propertyProvide a callable function for a given JSONPath in
jsonpath_coerce
dictionary.Example implementations
Implementation Considerations
@aaronsteers on Slack:
Slack discussions:
The text was updated successfully, but these errors were encountered: