<@U04S8PLJWMT> We get linkedin urn in columns when...
# ask-ai
g
@kapa.ai We get linkedin urn in columns when we fetch the data from linkedin using airbyte.... Now i need to transform it into values.. And i can get values only from the linkedin api... So how can i achieve this?
k
When you fetch data from LinkedIn using Airbyte, especially from Ad Analytics streams, you will often see URNs (Uniform Resource Names) in columns such as
pivotValue
. These URNs are LinkedIn's way of uniquely identifying entities like campaigns, creatives, accounts, etc. To get the human-readable values (like campaign names), you need to resolve these URNs using LinkedIn's API. How to transform URNs into values: 1. Extract URNs from your Airbyte-synced data. - For example, you might have a column like
pivotValue
containing values such as
urn:li:sponsoredCampaign:123456789
. 2. Use LinkedIn's API to resolve URNs. - LinkedIn provides endpoints (such as Organization Lookup, Campaign Lookup, etc.) that allow you to fetch details about these entities using their URNs. - For example, to resolve a campaign URN, you would use the [Campaigns API](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/ads/account-structure/create-and-manage-campaigns?tabs=http&view=li-lms-2023-05#search-for-campaigns) and pass the URN as a parameter. 3. Join the resolved values back to your analytics data. - After fetching the details (like campaign name, account name, etc.) from the LinkedIn API, you can join this information back to your analytics data using the URN as the key. Note: Airbyte does not automatically resolve URNs to human-readable values. This transformation must be done as a post-processing step after your sync, using additional API calls to LinkedIn. For more details on URN formats and how to resolve them, refer to the [LinkedIn documentation on URN resolution](https://learn.microsoft.com/en-us/linkedin/marketing/urn-resolution?view=li-lms-2023-05) and the [Airbyte LinkedIn Ads source documentation](https://docs.airbyte.com/integrations/sources/linkedin-ads#supported-streams). Summary: - Airbyte syncs URNs as-is. - You must use LinkedIn's APIs to resolve URNs to values. - This is a separate process outside of Airbyte's sync, typically done in your data transformation or enrichment pipeline. If you need more specific code examples or workflow suggestions, let me know!
g
@kapa.ai Okay iam not able to edit data in tables created by airbyte as it shows no primary key is ste what cna be done here.... And again here the sync happens daily how shud i manage this
k
A message from kapa.ai
The issue you're facing—being unable to edit data in tables created by Airbyte due to missing primary keys—is common, especially when your MySQL server has
sql_require_primary_key
set to ON. MySQL requires every table to have a primary key in this mode, and Airbyte by default may create tables (like
_airbyte_destination_state
) without one, causing errors during syncs and when you try to edit data. How to resolve this: 1. Manually add a primary key to the affected table. For example, you can create the
_airbyte_destination_state
table with a composite primary key as shown below:
Copy code
sql    CREATE TABLE `_airbyte_destination_state` (      `name` varchar(255) NOT NULL,      `namespace` varchar(255) NOT NULL,      `destination_state` varchar(255) DEFAULT NULL,      `updated_at` datetime DEFAULT NULL,      PRIMARY KEY (`name`,`namespace`)    );
This approach was confirmed to resolve the issue for other users with the same problem [Destination MySQL - Unable to create or change a table without a primary key](https://github.com/airbytehq/airbyte/issues/40232). 2. Managing daily syncs: - If your syncs run daily, ensure that any tables Airbyte creates (including new ones for new streams) have primary keys. - For user data tables, you can define primary keys in Airbyte’s connection settings. If the source does not provide a primary key, you can specify one or use a combination of fields as a composite primary key. This can be set in the Airbyte UI when configuring the stream ([User-Defined Primary key](https://docs.airbyte.com/platform/using-airbyte/core-concepts/sync-modes/incremental-append-deduped#user-defined-primary-key)). - If you add new streams or tables, repeat the process to ensure primary keys are set. Important: - If you cannot modify the Airbyte-created tables directly every time (for example, if Airbyte drops and recreates tables), you may need to automate this process or adjust your Airbyte configuration to always set primary keys where possible. - For tables where a natural primary key does not exist, consider creating a synthetic one (e.g., using a UUID or a combination of fields). Summary: - Add primary keys to Airbyte tables in MySQL to comply with
sql_require_primary_key
. - Define primary keys in Airbyte’s stream configuration for all user data tables. - Repeat this process for new tables as your sync evolves. If you need more automation or have many tables, consider scripting the primary key addition as part of your sync workflow.
g
@kapa.ai What nonsense is this we do have alot of connections do you want me to sit and repeadt this process all the time?
k
A message from kapa.ai
I understand your frustration—manually adding primary keys for every table is not scalable if you have many connections. Based on the knowledge sources, Airbyte currently does not provide an automated way to always create tables with primary keys in the MySQL destination when the source does not define one. This is a known limitation, especially when your MySQL server enforces
sql_require_primary_key=ON
and Airbyte tries to create tables without primary keys, leading to sync failures or inability to edit data [Destination MySQL - Unable to create or change a table without a primary key](https://github.com/airbytehq/airbyte/issues/40232). The only documented workaround is to manually create the required tables with primary keys before running the sync, or to adjust the Airbyte configuration to specify primary keys for each stream where possible. Unfortunately, the knowledge sources do not mention any built-in feature or automation in Airbyte that would handle this for all tables and connections automatically. If this is a critical blocker, you may want to follow or comment on the related GitHub issues to express the need for this feature, as it has been raised by other users as well. For now, the process remains manual according to the available documentation and issue discussions.
g
@kapa.ai mine is postgres destination
k
A message from kapa.ai
If your destination is Postgres and you are unable to edit data in tables created by Airbyte because there is no primary key set, this is expected behavior: Airbyte does not automatically create primary keys in destination tables unless the source table has a primary key defined. This can make editing or updating data in those tables difficult. Key points from the knowledge sources: - Airbyte will only replicate primary keys to the destination if they exist in the source. If your source table does not have a primary key, the destination table will not have one either, and you may face issues with editing or updating data. - For incremental sync modes (especially Deduped + History), a primary key is required. If a table does not have a primary key, Airbyte will not allow you to select incremental sync for that table; only Full Refresh will be available. This is confirmed in the forum and documentation: > "the source table needs to have a primary key to be loaded incrementally, because it’s using the table primary key for downstream duplication if Incremental - Deduped history is enabled" [Postgres CDC: some tables have Incremental, others dont](https://discuss.airbyte.io/t/367) - If you add a primary key to your source table, Airbyte will pick it up in the next sync and create the corresponding primary key in the destination table. - Airbyte does not automatically add or manage primary keys in the destination if they are not present in the source. If you want primary keys in your destination tables, you must ensure they exist in your source tables or manually alter the destination tables after sync. However, this manual change may be overwritten by future syncs, as Airbyte manages the schema based on the source. Managing this with daily syncs: - If you manually add primary keys to destination tables, be aware that Airbyte may overwrite these changes during syncs, especially if the schema changes in the source. - The recommended approach is to ensure your source tables have primary keys, so Airbyte can propagate them to the destination automatically. - There is no built-in Airbyte feature to automate adding primary keys to destination tables if they do not exist in the source. Summary: - Airbyte does not add primary keys to destination tables unless they exist in the source. - For editable and incrementally synced tables, ensure your source tables have primary keys. - Manual changes to destination schema may be overwritten by Airbyte during syncs. If you need exact schema replication (including primary keys, indexes, etc.), Airbyte may not be the right tool for this use case, as noted by Airbyte support: > "Because of this sometimes you can’t achieve exactly same copies. For this cases you need to use other tools OR export the normalization module and edit as your needs." [Exact copy of one Postgresql DB](https://discuss.airbyte.io/t/3918) If you have further requirements, such as always having a primary key in the destination, you may need to use additional tools or custom scripts outside of Airbyte.
g
@kapa.ai in source they exist because iam using inceremnetal +deduped mode
k
A message from kapa.ai
If your source tables have primary keys and you are using Incremental + Deduped mode, Airbyte should recognize and use those primary keys for the destination tables as well. This is confirmed in the documentation: > Some sources are able to determine the primary key that they use without any user input. For example, in JDBC database sources, the primary key can be defined in the table's metadata. [Source-Defined Primary key](https://docs.airbyte.com/platform/using-airbyte/core-concepts/sync-modes/incremental-append-deduped#source-defined-primary-key) Additionally, the Incremental + Deduped sync mode requires a primary key to function: > The source table needs to have a primary key to be loaded incrementally, because it’s using the table primary key for downstream duplication if Incremental - Deduped history is enabled. [Postgres CDC: some tables have Incremental, others dont](https://discuss.airbyte.io/t/367) If you are not seeing primary keys in your Postgres destination tables despite having them in the source and using Incremental + Deduped mode, this is unexpected based on the documented behavior. In this case, please check the following: 1. Schema Discovery: Make sure you have re-run schema discovery in Airbyte after adding or modifying primary keys in your source tables. Sometimes, changes are not picked up until schema discovery is refreshed. 2. Connector Version: Ensure you are using a recent version of the Postgres source and destination connectors, as older versions may have bugs or limitations. 3. Sync Logs: Review the Airbyte sync logs for any errors or warnings related to schema propagation. If the issue persists even after these checks, it may be a bug or a limitation not covered in the current documentation. In that case, you may want to open a support ticket or GitHub issue with Airbyte, providing details about your setup and the problem. Summary: - With Incremental + Deduped mode and primary keys in the source, Airbyte should propagate primary keys to the Postgres destination. - If this is not happening, re-run schema discovery and check connector versions. - If the problem continues, it may require further investigation or support from the Airbyte team. Let me know if you need help with specific troubleshooting steps!