Skip to content

Instantly share code, notes, and snippets.

@padak
Last active November 8, 2017 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save padak/2a0c5b05b2954b468825b40d7096d36c to your computer and use it in GitHub Desktop.
Save padak/2a0c5b05b2954b468825b40d7096d36c to your computer and use it in GitHub Desktop.

How to update "Change since last" in input mapping?

I assume you want to change one specific input mapping in particular transformation - let's say https://connection.keboola.com/admin/projects/2013/transformations/bucket/228803413/transformation/293095736

So, follow these steps:

get you API token

Find you email under https://connection.keboola.com/admin/projects/2013/storage#/tokens and write it down somewhere (let's say my token is 2013-70130-xxxx)

list Transformation's config rows

Individual transformations under Transformation bucket are stored in config rows. API docs is here.

## List Configuration rows
curl "https://connection.keboola.com/v2/storage/components/transformation/configs/228803413/rows" \
     -H 'X-StorageApi-Token: 2013-70130-xxxx'

edit json cfg

If you're on the specific transformation is KBC, get its ID from URL. In my case, its "293095736". Find this ID in json CFG and get only configuration section (raw sample can be found in sample.row-configuration-section.json):

sample cfg

Once you have proper part of whole CFG, you can edit input mapping. In my case, I changed -58 days to -59 days.

update transformation

To update transformation, you have to call PUT method and update key configuration (Form URL Encoded)! See sample.put.sh with sample CURL. In OSX Paw REST client, it looks like following example:

PAW

Final check

Once you get 200 OK from our API, your transformation input mapping will have modified "Change Since Last" field and Transformation Bucket Versions (can be found here in UI https://connection.keboola.com/admin/projects/2013/transformations/bucket/228803413/versions) shows what have changed:

Modified Mapping

If you're stuck with modifying cfg, do not hesitate to contact our support directly from Keboola Connection UI!

## Update CFG TAPI
curl -X "PUT" "https://connection.keboola.com/v2/storage/components/transformation/configs/228803413/rows/293095736" \
-H 'X-StorageApi-Token: 2013-70130-xxxx' \
-H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
--data-urlencode "configuration={
\"output\": [
{
\"source\": \"TMPTABLEBUYERS_MONTHLY\",
\"destination\": \"out.c-main.table_buyers_monthly\",
\"primaryKey\": [
\"id\"
],
\"incremental\": true
}
],
\"queries\": [
\"/* HERE YOU'LL HAVE YOUR OWN SQL CODE */\"
],
\"input\": [
{
\"source\": \"in.c-rubicon-history.table-buyers\",
\"destination\": \"in.table-buyers\",
\"datatypes\": {},
\"whereColumn\": \"\",
\"whereValues\": [],
\"whereOperator\": \"eq\",
\"columns\": [],
\"changedSince\": \"-59 days\"
}
],
\"name\": \"table buyers monthly\",
\"packages\": [],
\"requires\": [],
\"backend\": \"snowflake\",
\"type\": \"simple\",
\"id\": \"293095736\",
\"phase\": \"2\",
\"disabled\": false,
\"description\": \"\"
}"
{
"output": [
{
"source": "TMPTABLEBUYERS_MONTHLY",
"destination": "out.c-main.table_buyers_monthly",
"primaryKey": [
"id"
],
"incremental": true
}
],
"queries": [
"/* HERE YOU'LL HAVE YOUR OWN SQL CODE */"
],
"input": [
{
"source": "in.c-rubicon-history.table-buyers",
"destination": "in.table-buyers",
"datatypes": {},
"whereColumn": "",
"whereValues": [],
"whereOperator": "eq",
"columns": [],
"changedSince": "-59 days"
}
],
"name": "table buyers monthly",
"packages": [],
"requires": [],
"backend": "snowflake",
"type": "simple",
"id": "293095736",
"phase": "2",
"disabled": false,
"description": ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment