-
Notifications
You must be signed in to change notification settings - Fork 186
Remove of null column in JDBC output when script function is present #116
Remove of null column in JDBC output when script function is present #116
Conversation
@@ -35,8 +36,9 @@ | |||
private String alias; | |||
private NestedType nested; | |||
private ChildrenType children; | |||
private SQLExpr expression; |
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 don't see the use of this new field member. Did I miss it anywhere?
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.
see answer below. It's part of upcoming PR that I've slipped here. I can move it into different PR or leave it as is, because the change will be part of next PR anyway
List<Field> groupByFields = select.getGroupBys().isEmpty() ? new ArrayList<>() : select.getGroupBys().get(0); | ||
|
||
for (Field selectField : select.getFields()) { | ||
if (selectField instanceof MethodField && !selectField.isScriptField()) { |
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 assume what we want exactly here is de-duplicate. The !selectField.isScriptField
check works on the assumption that there is no aggregate function implemented by painless script right? If so, is this true?
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.
It's even worse (because as per Elastic's DSL script aggregations can be for both Bucket and Metric aggregations), but it will require considerable redesign, because the process of transforming of parsed SQL into current domain model loses a lot of information. For example - for query like
select date_format(format), count(*)
from index
group by date_format(format)
order by date_format(format)
there's no easy way to understand that the date_format is actually the same, because at this stage we're operating only with transformed expressions.
Adding of SQLExpr into field information in this PR is related to future attempt to de-duplication that is necessary for order by.
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 OK to me, just address @dai-chen's concern.
Issue #, if available: 111
Description of changes:
Fix of JDBC output when there's script function in group by. It is done by additional analysis in schema preparation step to differentiate script and method fields.
After this fix the output
returns, as expected
Testing:
integration test, manual via Kibana UI
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.