hey just a little interesting scenario i’ve notice...
# troubleshooting
a
hey just a little interesting scenario i’ve noticed when messing with states. When specifying the following:
Copy code
name = "wfmhistoricaladherence-raw" 
primary_keys = ["$.userId"]
replication_key = "endDate"
I’ve noticed that calling the expected replication key methods, i get: •
self.get_starting_timestamp(self)
-> the config.start_date value, even if I have a datetime/ISO replication_key (2010-01-01T000000+00:00) • and
self.get_starting_replication_key_value(self.stream_state)
-> None But when I call
self.stream_state["replication_key_value"]
I get the replication value i’m after.
Copy code
tap-genesyscloud | time=2021-10-07 23:20:58 name=tap-genesyscloud level=INFO message=self.stream_state: {'replication_key': 'endDate', 'replication_key_value': '2021-10-07T12:05:44.311Z'}
tap-genesyscloud | time=2021-10-07 23:20:58 name=tap-genesyscloud level=INFO message=self.get_starting_replication_key_value from self: None
tap-genesyscloud | time=2021-10-07 23:20:58 name=tap-genesyscloud level=INFO message=self.get_starting_replication_key_value frin stream_state: None
tap-genesyscloud | time=2021-10-07 23:20:58 name=tap-genesyscloud level=INFO message=2010-01-01T00:00:00+00:00
Am I approaching this incorrectly? Been scratching my head around this for a few hours. • Using the Meltano SDK to initialise the tap project • calling these within
get_records()
so I can make an appropriate api call out • No changes to the tap related to state. Just the vanilla stuff in the base Stream class
v
When you call
get_starting_timestamp
you should also pass context along with it. That is how Meltano stores the context about this specific Stream "run"
That might fix everything for you 😄 Sometimes context is null, I had to some tricks with it here https://github.com/AutoIDM/tap-clickup/blob/main/tap_clickup/streams.py#L196 I believe they are fixing the issue I was working through with this MR https://gitlab.com/meltano/sdk/-/merge_requests/157/diffs but I"m not super clear on what this MR solves yet (haven't dove in but it's related to the override I was doing I think)
One thing I"ve been confused about is what's the difference between "starting replication value" and current replication value. What's the proper way to get the "current replication value".
I overrode
get_starting_replication_key_value
in the example above, and basically the method now means to me "Get me the State I want" thanks 😂
a
Thanks Derek! This is super super helpful man
v
Yeah no problem instead of calling timestamp directly, try using
get_starting_replication_key_value
first with context provided. That might get you there