https://slingdata.io logo
Hi, there is something that acts not in
# sling-help
m
Hi, there is something that acts not in the way that I excpected. Im using same api spec for different instaces. And for every one I have also different replication, the object name have server name in a suffix. The incremental value doesnt updated for target object but for source_stream.. So, the source stream is the same for every endpoint, so the value is overided by only source_stream and not taking in advence the target object also. For example I have next source stream: Helpdesk And for 3 different server for example: server1, server2, server3 There is 3 target tables: helpdesk_server1 helpdesk_server2 helpdesk_server3 In stat table I expected that there will be 3 incremetnal values based on the source of "helpdesk" and target object (that appears as column) for example: helpdesk, "stg"."helpdesk_server1",{"last_sync_date":"2025-01-28T00:00:00Z"},json helpdesk, "stg"."helpdesk_server2",{"last_sync_date":"2025-02-28T00:00:00Z"},json helpdesk, "stg"."helpdesk_server3",{"last_sync_date":"2025-03-28T00:00:00Z"},json But, what I have in the end, only 1 row of the replication that was the latest one like: helpdesk, "stg"."helpdesk_server3",{"last_sync_date":"2025-03-28T00:00:00Z"},json
f
hey @marikt94, interesting. What you’re seeing is the way it is actually designed. The Primary Key in the state table is only the stream_name (so it does not take account of the target object). So, what you can do is use a different state table for each of your replication. You can actually specify the full table name:
Copy code
env:
   SLING_STATE: my_db/state_schema.state_table
If you’re re-using the same replication file, you can pass it in as a env var:
Copy code
env:
   SLING_STATE: mb_db/state_schema.${SLING_STATE_TABLE}
or actually just pass in env var
SLING_STATE
without specifying it in the replication file.
But i can see it more clean to have only one state table, to make the PK stream_name + object_name… Let me think about that. That’s easy to change for DB used for state, but for file used as state, it’s a little more complicated
m
Im not using same replication, Im using same api spec file, for different replications. Yes, they are point to same state table. In my opinion, when its an API, it can be a lot of instaces.. holding table for everyone, feels "messy". I would like to know if your going to implement another approach that you mentioned, when the pk is actually stream and object name. And yes, as a state table, Im using db.
f
hey @marikt94 can you try latest dev build? PK should be stream+object names
m
Great, thanks! I will try it soon
hi, it still act the same.. Looks like it not replcaed by last stream that was runned, but it remains with the same target object name
f
Oh you know what, can you manually change the Primary key? it's set to
source_stream
, but now needs to be
source_stream
+
target_object
m
Ok, got it. So it should work also if I rebuild this table, right?
f
I just pushed that change, so in the next dev build yes
for now, do it manually
m
Still not working.. the PK now CONSTRAINT api_state_table_pk PRIMARY KEY (source_stream, target_object)
f
hmm, can you run with
DEBUG=TRACE
and see the query that is ran
m
:32:20?[0m ?[33mDBG?[0m ?[36mselect * from "stg"."api_state_table" where source_stream = 'getlinked_leads'?[0m?[90m [mark_sling-fSB]?[0m
does it means that it still use only source_stream as lookup?
f
ah
m
$ ./sling_dev.exe --version Version: 1.4.27.dev (2025-11-19)
to make sure that version is good
f
OK try with lates dev build
m
Perfect, works now! Thanks!
Does this update is already on prod?
f
hey @marikt94 not yet, next release is targeted this weekend