New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DBZ-3966 JsonTableChangeSerializer support serialization for defaultValue #2671
DBZ-3966 JsonTableChangeSerializer support serialization for defaultValue #2671
Conversation
Failed tests need to be fixed. |
@Jiabao-Sun, any insights on the test failures? Are you going to push a fix to this PR? |
@gunnarmorling Because we need to deal with some possible types of Thanks for your reply and I'm going to push a fix to this PR. |
@Jiabao-Sun Cool, thanks! Do you think you might re-use |
@jpechane Thanks! I'll try with it. |
c7c8f7b
to
8ba42a1
Compare
@gunnarmorling @jpechane Sorry for the late fix. It's much difficult to serialize the So, I added a new It works but changes a lot. |
843bfa2
to
7e5789e
Compare
Failed tests were fixed and the PR is ready now. |
@Jiabao-Sun I think this is nice approach, thanks! @Naros What is the current support of default values in Oracle connector? Is it properly supported yet so this PR is vlaid for it or not? @gunnarmorling This allows us finally to switch fully from DDL parsing to logical changes based history recovery. |
@Jiabao-Sun We are near the release of 1.7.0.Final. The PR will be merged right after the realse into 1.8 master. |
@jpechane OK. Thanks a lot. |
@jpechane I vaguely remember that the shortcoming of the Oracle connector is we don't have a column default value listener and parser for the DDL. So during snapshot we are able to get the values from the driver we don't capture and parse the value during streaming changes like we do for MySQL. |
@Naros, can you log a separate issue for default value support for the Oracle connector then? @jpechane, @Jiabao-Sun, other than Oracle support, is this PR good to go? If not, what's missing? |
@gunnarmorling This is good to go for me |
@gunnarmorling Done, see DBZ-4115. I could have sworn we had one previously but I didn't see one currently opened. |
7e5789e
to
a3ca796
Compare
Conflicts resolved. |
a3ca796
to
974b13e
Compare
c2509a5
to
6bc3b67
Compare
ac85a08
to
d5413ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the rework, @Jiabao-Sun!
I think we're getting there. One more comment inline, looks like things can be simplified some more. I'll take another look tomorrow my time, but I don't see any more large road blocks.
public Object defaultValue() { | ||
return defaultValue; | ||
return null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a left-over?
Also hasDefaultValue()
should not be needed any longer; as we now can differentiate whether a default value has been provided or not by examining the Optional
returned from defaultValueExpression()
. The explicit hasDefaultValue()
method was needed before as we could not tell differentiate between no default value given or a default value of null
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The left-over has been cleaned up.
I think we should keep hasDefaultValue
cause there are scenarios for implicit default values.
Usually, defaultValueExpression
is null and hasDefaultValue
is false.
But in the implicit case, defaultValueExpression
is null but hasDefaultValue
should be true.
In a word, the null defaultValueExpression
does not directly indicate whether the column has a default value.
https://dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this scenario needs to be concerned, then the hasDefaultValue
should also be serialized in TableChangeSerializer
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, that's a good point. Indeed we are exporting some "implicit default values" in certain cases, and my current thinking is we probably should not do this. But it seems largely independent from the matter at hand and fixing this also would be sort of a breaking change, so it's something we should leave for Debezium 2.0 (I'll add this to the list of things to be considered for that, see DBZ-3899). No re serializing hasDefaultValue
, I'd prefer if we'd not do that, given we should get rid of this entire implicit default value business at all. Admittedly, there'll be an inconsistency when reading back the schema history for such value, but I feel that's an acceptable limitation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @gunnarmorling for the detailed explanation.
I will remove all the hasDefaultValue
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'm just not sure whether we can or should do this at this point. Here's a PR where I did that (just look at the last commit): #2887. It changes some assertions, i.e. behavior exposed to consumers is slightly modified in some cases. @jpechane expressed concerns about doing this in a release like 1.8 (as opposed to a major release like 2.0). @jpechane, can you take a look at that last commit and the assertions I've changed; as stated below, I think one could also argue that the previous behavior actually was incorrect when it comes to those implicit default values.
Hi @Jiabao-Sun, thanks for your contribution. Please prefix the commit message(s) with the DBZ-xxx JIRA issue key. |
0c9cb7e
to
ad12282
Compare
ad12282
to
fea6ac6
Compare
@Jiabao-Sun, pushed one more commit to return |
@gunnarmorling |
Yes, you are right. So I think we have two options at this point:
@Jiabao-Sun, @jpechane, which option would you prefer? I'm on the fence, I think I'm slighly leaning towards removing it, as I feel it's more about rectifying previous, buggy behavior rather than breaking correct, expected behavior. But I'm open for both options really. |
Personally, I prefer the first option. |
Ok, so let's do this then. Thanks a lot for iterating over this with us, really appreciating your efforts, @Jiabao-Sun! Are you going to push another commit for adding that serialization work? I'll log an issue describing the follow-up work, also linking to that branch of mine with the preliminary work for it. Thx! |
OK, I will push another commit to complete it. |
Hi @Jiabao-Sun, thanks for your contribution. Please prefix the commit message(s) with the DBZ-xxx JIRA issue key. |
e4d8b30
to
8d306a3
Compare
Hi @Jiabao-Sun, thanks for your contribution. Please prefix the commit message(s) with the DBZ-xxx JIRA issue key. |
Rebased and applied. Thanks a lot, @Jiabao-Sun! |
I've logged https://issues.redhat.com/browse/DBZ-4239 as a follow-up for removing |
Thanks, Cheers! |
Both JsonTableChangeSerializer and ConnectTableChangeSerializer ignored defaultValue, hasDefaultValue, enumValues of ColumnImpl.
If we serialize and then deserialize the TableChanges, missing default value may cause:
https://issues.redhat.com/browse/DBZ-3966