Is it somehow possible to get flink to enforce pri...
# troubleshooting
r
Is it somehow possible to get flink to enforce primary keys specified with the schema object? I run into the problem that my changelog isn't working because the primary keys arent enforced and an additional column that was introduced later now completely breaks the changelog mechanism for me - I wont get any deletes anymore 😞
m
Given that Flink isn’t the data store, how could it enforce primary keys?
r
Generally I'm just a little bit confused, that Flink isnt able to ignore the column I added
m
Without context I can’t assess what’s wrong. This thread doesn’t contain enough information
r
@Martijn Visser Sorry, my work day already ended before I got your answer. Essentially our table is created through an sql query and we modified the SQL Query to look like this:
Copy code
Select XYZ as XYZ, ..., NOW() as SomeTimeColumnName From SomeSourceTable
We added that
NOW() as SomeTimeColumnName
and that essentially broke the complete changelog creation.
m
That makes sense, because
NOW()
always return a non-deterministic result. Executing that query at T0 returns result A, while running that at T1 would return result B. So the problem seems to be that you're running a query that's not deterministic.
r
However, structure wise the change is deterministic though but if that isn't enough Flink then there isn't much one can do about this.
Thanks for your answer btw
m
structure wise the change is deterministic though
How? If you recover from a checkpoint that was made 5 minutes ago, how would you get exactly the same result?
(I do think we're diverging a bit from your original question but I also don't think they are related to one another, and that there's actually a different problem you're experiencing)
r
It seems the determinism is the source of the problem here apparently. However in this case it is intended for the result to be different to a different point in time - after all it should save when a record was created. However I was already thinking that this could have been done differently with Flink, because Flink apparently supports specific features for such use cases.
m
after all it should save when a record was created.
No it shouldn't, from the docs:
For Flink SQL, the determinism provided is limited to the computation only, because it does not store user data itself (here it is necessary to distinguish between the managed internal state in streaming mode and the user data itself), so the Source connector’s implementation that cannot provide deterministic back read will bring non-determinism of the input data, which may produce non-deterministic results.
https://nightlies.apache.org/flink/flink-docs-master/docs/dev/table/concepts/determinism/#non-deterministic-back-read-of-source-connector
r
That's why I ended up with an implementation that essentially adds that column manually just before it is send out onto the topic. In this case I wouldnt expect any problems because the column isnt processed any further by Flink.
Thank you very much for the insight @Martijn Visser
👍 1