Dustin Pearson
03/17/2023, 4:38 PM{
"properties": {
"CUSTOM_KEY_1": INT|STR|ARRAY,
"CUSTOM_KEY_2": ...,
...
}
}
Problem
• There is no way to detect this property list besides listing every item from the endpoint (a full refresh)
• A full refresh will take over an hour for users with >= 500,000 leads in Klaviyo
◦ 60 requests per second, 100 max page size => (500000)/(6000) = 83 minutes
Investigation
• I have looked through the codebase trying to find an example of supporting an object with a dynamic number of properties. I cannot find such a use case.
• Codebase Examples
◦ The Airtable integration has top-level "Base" or "Table" concepts which would have very few entities. It extracts the properties from there
◦ The Mixpanel integration seems to be doing a full refresh of every Profile in Mixpanel to do this
Options
• (Love) A better solution from someone in this chat
• (Like) Find a way to store a JSONB column with this dynamic list of properties and allow Airbyte customers to handle extractions themselves
• (Dislike) Behave like the Mixpanel integration and do a full refresh to determine properties.Sherif Nada
03/17/2023, 5:27 PMDustin Pearson
03/17/2023, 5:34 PMprofiles.json file, but when I actually used this as a custom connector, the properties key still displayed as null:
{
"type": "object",
"properties": {
"type": { "type": "string" },
"id": { "type": "string" },
"updated": { "type": "string", "format": "date-time" },
"properties": { "type": "object" },
}
}
Is there some other customization that I need to do in the code or schema to ensure we can push to the properties column even though it has no additional definition beyond the type?Sherif Nada
03/17/2023, 5:46 PMDustin Pearson
03/17/2023, 6:12 PMprofiles.json to have the configuration above instead of what is in the PR
• I created pushed a private docker container and used it as a custom connector
Data
• Inside of the database _klaviyo_test schema:
◦ We have a _airtable_raw_profiles table which contains the full expected response, including the full properties for each profile.
• We have a profiles table at which contains just a null value for each row in this columnSherif Nada
03/17/2023, 6:16 PMDustin Pearson
03/17/2023, 6:23 PMMarcos Marx (Airbyte)
03/17/2023, 6:25 PMDustin Pearson
03/17/2023, 6:37 PMpython main.py read --config secrets/config.json --catalog integration_tests/configured_catalog.json , then yes, it includes those fields
Here is one of the profiles that are output from running that command:
{
"type": "RECORD",
"record": {
"stream": "profiles",
"data": {
"type": "profile",
"id": "OBFUSCATE_ID",
"attributes": {
"email": "test@nutrisense.io",
"phone_number": null,
"external_id": null,
"anonymous_id": null,
"first_name": "FAKE_FIRST",
"last_name": "FAKE_LAST",
"organization": null,
"title": null,
"image": null,
"created": "2023-01-27T14:06:06+00:00",
"updated": "2023-02-27T15:14:06+00:00",
"last_event_date": "2023-01-27T14:06:09+00:00",
"location": {
"address1": null,
"address2": null,
"city": null,
"country": null,
"latitude": null,
"longitude": null,
"region": null,
"zip": null,
"timezone": null
},
"properties": {
"Full Name": "FIRSTNAME LASTNAME",
"Subscribed To": [
"Marketing",
"Account",
"Newsletter",
"Promotions"
],
"Newsletter - Subscription - Source": "checkout",
"Registration - Date Created": "2023-01-27T14:06:03Z",
"Eng Identify User Origin": null
},
"subscriptions": {
"email": {
"marketing": {
"consent": "NEVER_SUBSCRIBED",
"timestamp": null,
"method": null,
"method_detail": null,
"custom_method_detail": null,
"double_optin": null,
"suppressions": [],
"list_suppressions": []
}
},
"sms": {
"marketing": null
}
}
},
"links": {
"self": "https://a.klaviyo.com/api/profiles/OBFUSCATE_ID/"
},
"relationships": {
"lists": {
"links": {
"self": "https://a.klaviyo.com/api/profiles/OBFUSCATE_ID/relationships/lists/",
"related": "https://a.klaviyo.com/api/profiles/OBFUSCATE_ID/lists/"
}
},
"segments": {
"links": {
"self": "https://a.klaviyo.com/api/profiles/OBFUSCATE_ID/relationships/segments/",
"related": "https://a.klaviyo.com/api/profiles/OBFUSCATE_ID/segments/"
}
}
},
"updated": "2023-02-27T15:14:06+00:00"
},
"emitted_at": 1679077848765
}
}Dustin Pearson
03/17/2023, 6:42 PM_airbyte_raw_profiles, the issue is definitely related to the data normalization, right?
I cannot find clear instructions on how to test thatSherif Nada
03/17/2023, 6:48 PMDustin Pearson
03/17/2023, 7:25 PM["object", null"] notation
• I created v0.2.2 of the connector with just "object" for properties
• I failed to refresh the source schema
I've just went through the process of refreshing the source schema and see that the Data type switched from nullobject -> object
Weirdly, when we have a nullobject, the UI still displays the Data Type as "Object" so it isn't immediately clearDustin Pearson
03/17/2023, 7:25 PMDustin Pearson
03/17/2023, 8:23 PM_klaviyo_test.profiles table.
Here is a screenshot of the schema. There aren't any nested propertiesSherif Nada
03/17/2023, 8:24 PMDustin Pearson
03/17/2023, 8:28 PMairbyte_raw_profiles
In that case, I guess I'll just wait for a member of the airbyte team to review the PR.Dustin Pearson
03/17/2023, 8:28 PMSherif Nada
03/17/2023, 8:30 PMprofiles has field properties: {type: object, additionalProperties: true} . The value of this field is propagated to _`profiles_raw` in postgres but the normalized table profiles only has nulls in that column.Ryan Fu (Airbyte)
03/17/2023, 9:19 PMtype: [some_data_type_here, object] is set and also the case with nested objects. Github issue: Normalization handles type: [X, object] schemas
As for support for jsonb that is actually something we're actively looking to prioritize, @Edward Gao (Airbyte) is leading the charge for that feature and will let him speak more about that
Regarding your normalized table still showing null values, is the entire profiles.properties column null or are the most recent syncs including objects in that column? Suspect the issue is because normalization is executing on the most recent records synced not all the existing data in _airbyte_raw_profiles.Dustin Pearson
03/17/2023, 9:43 PM"properties": { "type": "object" }
I did:
• Refresh source schema and reset data
• Multiple syncs of thousands of updated records
Result:
• Still the properties column in the profiles table is null.Ryan Fu (Airbyte)
03/17/2023, 10:00 PM:dev instance of source-klaviyo? In the PR you linked I still see "properties": { "type": ["null", "object"] }. In the past, I've seen instances where rebuilding a dev version of a connector and running syncs locally the dev connector doesn't actually pick up the changes. It may not be the case here, however, "properties": { "type": "object" } has been successful for other connections so this would either be some regression in normalization or the schema is being passed in with the [null, object] still
Could you connect to the airbyte-db and see within your connection table what the catalog looks like? it should include the schema being passed into normalization, if your catalog is indeed showing "properties": { "type": "object" } then more investigation needs to be doneDustin Pearson
03/17/2023, 11:55 PM"properties": { "type": "object" }
• Built and published a new docker image with a new version to ECR
• SSH into my airbyte container on GCP and pull the tagged docker image
• Visit airbyte console and switch to new version of docker image
• Visit airbyte console and click "Refresh source schema"
◦ See screenshot below of when that happened
• Check yes to reload full schema
◦ This triggered deletion of all rows and resynced everythingDustin Pearson
03/17/2023, 11:55 PMconnections table in the airbyte postgres database we have on google cloud. It gave this output:
{
"streams": [
{
"stream": {
"name": "profiles",
"json_schema": {
"type": "object",
"properties": {
"id": {"type": "string"},
"type": {"type": "string"},
"links": {"type": ["null", "object"]},
"updated": {"type": "string", "format": "date-time"},
"segments": {"type": ["null", "object"]},
"attributes": {
"type": "object",
"properties": {
"email": {"type": "string"},
"title": {"type": "string"},
"created": {"type": "string", "format": "date-time"},
"updated": {"type": "string", "format": "date-time"},
"last_name": {"type": "string"},
"first_name": {"type": "string"},
"organization": {"type": "string"},
"phone_number": {"type": "string"},
"last_event_date": {"type": "string", "format": "date-time"}
}
},
"properties": {"type": "object"},
"relationships": {"type": ["null", "object"]},
"subscriptions": {"type": ["null", "object"]}
}
},
"default_cursor_field": ["updated"],
"supported_sync_modes": ["full_refresh", "incremental"],
"source_defined_cursor": true, "source_defined_primary_key": [["id"]]
},
"sync_mode": "incremental",
"primary_key": [["id"]],
"cursor_field": ["updated"],
"destination_sync_mode": "append_dedup"
}
]
},
{"units": 1, "timeUnit": "hours"},
f,null,2023-03-17 01:36:13.057445+00,2023-03-17 20:21:54.517078+00,d4af1271-007c-4de5-9531-67fbf44b76a1,basic_schedule,
{
"basicSchedule": {
"units": 1,
"timeUnit": "hours"
}
}",
AUTO,t,ignore,f,f,
{
"null/flows": false,
"null/lists": false,
"null/events": false,
"null/metrics": false,
"null/profiles": false,
"null/campaigns": false,
"null/global_exclusions": false
}Dustin Pearson
03/17/2023, 11:58 PMRyan Fu (Airbyte)
03/20/2023, 8:14 PMDustin Pearson
03/20/2023, 8:30 PMDustin Pearson
03/23/2023, 2:11 PMairbyte_raw_profiles, it actually just nests a new properties key under attributes.
I am guessing this is due to some bug in the way the schemas work.Dustin Pearson
03/23/2023, 2:19 PM{
"attributes": {
"email": "jpires11@icloud.com",
},
"properties": {
"PROPERTY1": "test",
}
}
Example of how this is being stored:
{
"attributes": {
"email": "jpires11@icloud.com",
"properties": {
"PROPERTY1": "test",
}
},
}
We will need to think of a solution to this problem.
A simple solution could be to load the properties data into a new field with a different name at the top-level, but maybe someone has a better idea?Dustin Pearson
03/23/2023, 2:40 PM