I am stumped so need help. I am running a tap-post...
# plugins-general
t
I am stumped so need help. I am running a tap-postgres in INCREMENTAL replication mode by specifying a surrogate key as replication key. Although source data has not changed. I see Meltano updating target table although I am expecting no change since no new id has been inserted. Is this the expected behavior?
d
@timothy_suh That's not expected behavior, no. Do you have the
meltano elt
output for the run that updated the target table unexpectedly?
t
My meltano.yml config:    metadata:     idme_core-public-appointment_slots:      replication-method: INCREMENTAL      replication-key: id
meltano     | Running extract & load... meltano     | No state was found, complete import.
Regardless of replication method, it seems like Meltano is always upserting
d
Copy code
meltano     | No state was found, complete import.
Here's your issue 🙂 Apparently Meltano is not able to find the most recent run's state (https://meltano.com/docs/integration.html#pipeline-state), so it's not able to tell the extractor where the last run left off and where it should start off now, so the extractor is just starting from scratch again
Are you passing a
--job_id=<name>
when running
meltano elt
?
If so, do all runs of
meltano elt
have access to the same system database (https://meltano.com/docs/project.html#system-database), which is where the incremental state is stored?
And last but not least, does
tap-postgres
have
state
under
capabilities
in
meltano.yml
?
t
Let me check
When I pass in job_id, it looks better: meltano     | Running extract & load... meltano     | Found state from 2020-09-22 223421.699487.
Why does it still update one row though? target-postgres | INFO UPDATE 1 target-postgres | INFO INSERT 0 0
d
If you run
meltano --log-level=debug elt ...
(debug mode: https://meltano.com/docs/command-line-interface.html#debugging), you should be able to see the
RECORD
message output by
tap-postgres
t
extractors:  - name: tap-postgres   namespace: core   pip_url: tap-postgres   executable: tap-postgres   capabilities:   - discover   - properties   - state
Very interesting. The last row as stored in the state is always updated.
t
You are right, it's greater than or equal to WHERE {} >= '{}'::{}
d
I'd argue that that's incorrect, since not all targets handle duplicate records correctly, but I'm not sure why Stitch decided to do it this way
t
In general, incremental should not work this way. I agree w/ you.
d
Is this behavior acceptable for you, now that state tracking is actually working?
t
I think so. Thank you for your help.
d
Awesome, my pleasure!