Hi, I am trying to build a tap 'tap-jsonplaceholde...
# meltano-plugin-development
f
Hi, I am trying to build a tap 'tap-jsonplaceholder ' for the following schema: { "timezones": [ { "timezone": { "local_time": "", "description": "[GMT-10:00] Pacific/Tahiti", "name": "Pacific/Tahiti", "ref_timezone_id": 3, "utc_offset": -36000 } } ] } for which I'm trying to create a stream schema: class CommentsStream(jsonplaceholderStream): .... schema = th.PropertiesList( th.Property( "timezones", th.ArrayType( th.Property( "timezone", th.ObjectType( th.Property("local_time", th.StringType), th.Property("description", th.StringType), th.Property("name", th.StringType), th.Property("ref_timezone_id", th.IntegerType), th.Property("utc_offset", th.IntegerType), ), ), ), ), ).to_dict() ..... • I run the meltano cmd line: meltano run tap-jsonplaceholder target-json • I get the following output: {"timezones": [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]} The logging of the schema object give me this output: 2024-07-29 150355,462 - root - INFO - {'type': 'object', 'properties': {'count': {'type': ['integer', 'null']}, 'execution_time': {'type': ['string', 'null']}, 'timezones': {'type': ['array', 'null'], 'items': {'type': 'object', 'properties': {'local_time': {'type': ['string', 'null']}, 'description': {'type': ['string', 'null']}, 'name': {'type': ['string', 'null']}, 'ref_timezone_id': {'type': ['integer', 'null']}, 'utc_offset': {'type': ['integer', 'null']}}}}}} I can see the 'items' key but I cannot see the 'timezone' key (defined as a property above). I think this is the source of the issue. However, I am not sure how to correct this. I cannot see whether my PropertiesList defintion is wrong. Could you enlighten please? Thank you very much for your time
r
Try wrapping the array item definition in `PropertiesList`:
Copy code
schema = th.PropertiesList(
    th.Property(
        "timezones",
        th.ArrayType(
            th.PropertiesList(
                th.Property(
                    "timezone",
                    th.ObjectType(
                        th.Property("local_time", th.StringType),
                        th.Property("description", th.StringType),
                        th.Property("name", th.StringType),
                        th.Property("ref_timezone_id", th.IntegerType),
                        th.Property("utc_offset", th.IntegerType),
                    ),
                ),
            ),
        ),
    ),
).to_dict()
āž• 1
f
This was the problem indeed! Thank you so much for the prompt response!
np 1
r
FYI,
PropertiesList
is just a convenience wrapper class for
ObjectType
, so you can use that instead if you prefer (like how you have already used
ObjectType
). šŸ™‚
ā¤ļø 1
šŸ‘ 1