Hello! Me again :slightly_smiling_face: I am tryin...
# help-connector-development
r
Hello! Me again 🙂 I am trying to find a way to
increment - append
data instead of
full refresh - overwrite/append
with the low-code CDK. Here's how the data is structured:
Copy code
testdata = { 
  'rows': [
    {
      'data_row1': [{ 'kpi': 2, 'date': "2022-11-07" }],
      'metadata_row1': {'id': 1}
    },
    {
      'data_row2': [{ 'kpi': 8, 'date': "2022-11-07" }],
      'metadata_row2': {'id': 2}
    },
  ]
}
• To get all rows, I need to set
record_selector
on
rows
field • But to get the date field (enabling increment with slicing) I need to set the
cursor_field
to something like that:
["data_row1", "0", "date"]
or
data_row1[0]['date']
. ◦ With 1st solution, I have an error because it won't accept a list ◦ With 2nd solution, the script runs but the cursor is not working and displays older data than what's in
sample_state.json
I'm wondering, is there actually a way to activate increment on this kind of data? It's the last step before I can contribute for a new connector 🙏
1
Also, I tried by setting
record_selector: ["rows", "0", "data_row1"]
+
cursor_field: "date"
and it worked well, but it's not correct as I'm only getting the first row for each call. It's when I am nesting the cursor_field that it's simply not working anymore 😕
b
hey rachel! so unfortunately the framework doesn’t currently support using a nested cursor field and can only select at what is at the top level. We do have a ticket tracking this, but we haven’t had a chance to figure out when we’ll tackle it.
one idea could be to use an add field transformer to “move” the field to the top level where it can then be used as a cursor. that could be a possible solution. I did want to clarify the example you sent, so for each row item, the object will have different field names like
data_row1
or
data_row2
?
💡 1
r
oh! thank you so much for this clever workaround, it actually worked with an added field that is then called as a cursor 🎉
the object has the same name actually, more like
data_row
for each row item
I used something like this for the added field:
Copy code
path: ['date']
value: ' {{ stream_slice['end_time'] }}'
then I was able to call
'date'
in cursor field, which was finally stored in state 🥳
I’ll be posting the PR for new connector soon loading
b
Glad to hear it! When you mentioned different field names in the example, I wasnt sure if that would work since the transformer wouldn't be able to handle the changing field, but happy to hear it worked for your connector 🙂