-
Notifications
You must be signed in to change notification settings - Fork 118
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
Translate vector-type fields properly in DDlogJooqProvider #1089
Conversation
Signed-off-by: Amy Tai <amy.tai.2009@gmail.com>
throw new DDlogJooqProviderException("Unknown datatype " + field); | ||
// Return a value based on the DDlog type of the record | ||
private static Object ddlogRecordToObject(final Field<?> field, final DDlogRecord in) { | ||
if (in.isBool()) { |
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.
How about adding a 'debug' flag which will cause the code to assert that the SQL type matches as well?
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.
Done, for the simple types. For compound types (such as vector/array), the SQL type simply shows up as Object, which is the entire reason for this PR.
return in.getFloat(); | ||
} else if (in.isString()) { | ||
return in.getString(); | ||
} else if (in.isStruct()) { |
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.
how come that the original code didn't have this path?
were there no nulls so far in the tests?
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.
Good point.
Previously, nulls were checked for outside this function (see DDlogJooqProvider::structToValue, which calls this function after inspecting for struct).
This path is more robust in the case of nested types, so I've removed structToValue
and replaced it with setValue
.
public void testArrayAggTypes() { | ||
assert(create != null); | ||
create.execute("insert into \nhosts values ('n1', 10, true)"); | ||
create.batch("insert into hosts values ('n54', 18, false)", |
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.
none of your tests has an array with more than 1 element, or with a null element.
is it possible to add these?
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.
Added both types of array results.
Signed-off-by: Amy Tai <amy.tai.2009@gmail.com>
Signed-off-by: Amy Tai amy.tai.2009@gmail.com
Previously, vector-type columns (i.e. ARRAY_AGG) would not get properly handled by the DDlogJooqProvider during writeback (DDlogJooqProvider::onChange), because the Jooq H2 backend stores the type of array columns as Object.class. Instead, in the writeback function, we infer the type of the column from the DDlog record, which should have all typing informaiton.