Store Shopify Data to BigQuery using Shopify Connector

Hi, 

I am trying to fetch and store the Shopify's data to BigQuery using Shopify's connector. I have added two connectors, one of them has a REST schema and the second one has a GRAPHQL schema. Both connectors have an active status. How can I fetch and store the Shopify's data using this connector? Is it possible to do so using Google API? 

Kind regards, Iana

 

Solved Solved
0 15 2,127
1 ACCEPTED SOLUTION

@Meenchou helped to create the sub-integration and connect it to the main integration. That solved an issue.

View solution in original post

15 REPLIES 15

Kindly select the Shopify connection configured with REST schema and configure LIST operation in Connector task in Application Integration. LIST operation allows to fetch data  records from Shopify. Example listed below can be helpful for step wise explanation

https://cloud.google.com/integration-connectors/docs/perform-crud-operation-mysql-database

Hi @Madhuvandhini ,

Thank you for your response. I added the Shopify connector in the Application Integration and it gives the required results in a form of array. Also I added a BigQuery connector in order to pass the fetched data to the warehouse. There are some instructions given here: https://cloud.google.com/application-integration/docs/insert-data-bigquery-for-each-parallel-task?_g.... However, the data fetched from the Shopify's connector does not pass as an input to the BigQuery connector as BigQuery connector requires an input in a form of an object. Could you suggest how an array can be passed an an object to BigQuery connector to store the data there? Is there some proprocessing needed. 

Hi @ianala 

you can use data mapping task to convert your array to an object (store it in a json variable)

try this mapping in the data mapping editor

arrayVar.TO_JSON() -> jsonVar

you should be able to pass jsonVar as an input to the BigQuery connector

Hi @Meenchou ,

Thanks a lot for your comment. I've converted the output of Shopify's connector to string array and then TO_JSON and created an variable with the object with the following JSON schema: {
"type": "object"
}. Consequently, the created variable (connectorOutputPayload_object) is added as an input and the `ConnectorInputPayload (BigQuery)` is added as an output.When I test the integration, it throws the same error saying "Message: instance type (array) does not match any allowed primitive type (allowed: ["object"]) Schema Path:"". Could you guide what the issue could be with the convertation?

ianala_0-1689936364272.png

 

@ianala 

Can you try this

ConnectorOutputPayload (Shopify Rest). TO_JSON() -> ConnectorOutputPayload_object

@Meenchou 

To_JSON() is not displayed in the list of possible functions to apply to ConnectorOutputPayload (Shopify Rest). 

ianala_0-1689939679569.png

 

Kindly send  private message to me with details of project name and integration name. We will look into it and revert back

I've sent you a PM. 

@Meenchou helped to create the sub-integration and connect it to the main integration. That solved an issue.

It seems like bigQuery connector input payload is expecting a single object and not an array

you can use foreach loop task to loop through that array and call the subintegration which would eventually call big query connector and the output from the task can be collected in your parent integration parent_intg.pngsubintg.png

Note:Publish the subintegration first and then refresh your parent integration 

If you want to test the flow, you should directly invoke the parent integration and the value will be automatically set from parent integration 

If you just want to invoke your subintegration for testing purpose, then you need to provide the input value

Is it possible to get more details of how the data mapping was configured?

I'd like to do this too. Could you provide some more details @Meenchou or @ianala?

Hi,
Shouldnt we use Create operation for Bigquery connector here instead of List  since we want to store the data in Bigquery. Whats the point of keeping it as list operation here? I'm confused

You are correct, the LIST operation is like a SELECT * FROM Table Where Filter ; operation, so it will return a list of results.  You would want to use the Create operation to insert a row into BigQuery (in a loop for many rows)...

Here is a flow that does Shopify to Sheets and to BigQuery for the Product object in Shopify.  I have a couple of extra branches which do a list of the existing data in Sheets and in BigQuery, so that I can view that in the execution logs to see the before and after my inserts.  These are completely optional and can be removed if you want.  I've found it helpful to do a LIST operation just so I can get some sample data in the logs and that helps me to figure out the business meaning of each of the fields I need to map (and can be used as the structure for my Data Transformer task's script).

You will see that the BigQuery connector is in the second integration flow to the right, and it is called by the For Each Loop (ID:17).   There is a way to do batch updates with a job, etc..., but I just wanted something simple when I was developing this, so I did a loop with the Create operation on the BigQuery Connector, which takes one row at a time.   Also note that I have 2 triggers on the sub-integration to write a row to BigQuery.  This is also optional.  The recommended trigger to use is the Private Trigger.  The API trigger is there in case I want to call this sub-integration as an API from some external code someday in the future.  The Private trigger can only be called by another integration in the same project, while an API Trigger will always create a Public API (secured by IAM) (for example, this can be called from an Apigee Proxy).

shaaland_0-1712091518875.png

Here are the Shopify connection task configurations:

Screenshot 2024-04-02 at 2.02.24 PM.pngScreenshot 2024-04-02 at 2.02.56 PM.png

I used the new Data Transformer Task (Preview) for all of my main data mappings from Shopify to Sheets and BigQuery formats.  If there is interest, I can share these details as well.  I found the Shopify data structure a bit challenging because some of their JSON substructures had stringified JSON in them, so I had to add an extra parseJson command for those sub structures.

Hope that helps!

And here is the BigQuery Connection configuration (Task ID:15) ... I used the "Entity" option, and selected my dataset "shopify.products" and the "Create" operation 

Screenshot 2024-04-02 at 2.15.10 PM.png