Also Can a Stream have a object as a field in a ta...
# getting-started
r
Also Can a Stream have a object as a field in a tap? like
Copy code
... 'user': {'id': 1, 'name': 'Rithesh S', 'firstName': 'Rithesh', 'lastName': 'S'} ...
a
Welcome, @rithesh_s! Yes, to answer this question you can have objects in the stream nested to any depth - and you have a few options on how to specify their schema. Some developers (especially if they already know JSON Schema or already have a schema.json file created) will just specify the path at
Stream.schema_filepath
. The second option is to set a Python dictionary object in
Stream.schema
which contains the JSON Schema definition. My own personal preference is to use the second option, using the helper classes from the SDK, so the entire JSON schema structure can be declared in Python. Here's an example of a very complex structure being defined in Python with the helper classes: https://github.com/dataops-tk/tap-powerbi-metadata/blob/main/tap_powerbi_metadata/streams.py#L119 Note at the end of that declaration is a
.to_dict()
call which converts the large constructed object back to native python dictionary.
r
Yes I am using the helper functions which has types like th.ObjectType. The SDK seems to take care of everything, its very nice!!!