-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
SQL: Fix esType for DATETIME/DATE and INTERVALS #38179
Changes from 4 commits
5c7ff99
508f53f
7dd0a81
ea18004
3057fd7
4fed2fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -632,16 +632,16 @@ public void testTopHitsAggregationWithOneArg() { | |
"\"sort\":[{\"keyword\":{\"order\":\"asc\",\"missing\":\"_last\",\"unmapped_type\":\"keyword\"}}]}}}}}")); | ||
} | ||
{ | ||
PhysicalPlan p = optimizeAndPlan("SELECT LAST(keyword) FROM test"); | ||
PhysicalPlan p = optimizeAndPlan("SELECT LAST(date) FROM test"); | ||
assertEquals(EsQueryExec.class, p.getClass()); | ||
EsQueryExec eqe = (EsQueryExec) p; | ||
assertEquals(1, eqe.output().size()); | ||
assertEquals("LAST(keyword)", eqe.output().get(0).qualifiedName()); | ||
assertTrue(eqe.output().get(0).dataType() == DataType.KEYWORD); | ||
assertEquals("LAST(date)", eqe.output().get(0).qualifiedName()); | ||
assertTrue(eqe.output().get(0).dataType() == DataType.DATETIME); | ||
assertThat(eqe.queryContainer().aggs().asAggBuilder().toString().replaceAll("\\s+", ""), | ||
endsWith("\"top_hits\":{\"from\":0,\"size\":1,\"version\":false,\"seq_no_primary_term\":false," + | ||
"\"explain\":false,\"docvalue_fields\":[{\"field\":\"keyword\"}]," + | ||
"\"sort\":[{\"keyword\":{\"order\":\"desc\",\"missing\":\"_last\",\"unmapped_type\":\"keyword\"}}]}}}}}")); | ||
"\"explain\":false,\"docvalue_fields\":[{\"field\":\"date\",\"format\":\"epoch_millis\"}]," + | ||
"\"sort\":[{\"date\":{\"order\":\"desc\",\"missing\":\"_last\",\"unmapped_type\":\"date\"}}]}}}}}")); | ||
} | ||
} | ||
|
||
|
@@ -661,17 +661,17 @@ public void testTopHitsAggregationWithTwoArgs() { | |
|
||
} | ||
{ | ||
PhysicalPlan p = optimizeAndPlan("SELECT LAST(keyword, int) FROM test"); | ||
PhysicalPlan p = optimizeAndPlan("SELECT LAST(date, int) FROM test"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this change required by the types change in this PR or you just wanted some diversity in FIRST/LAST tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to test the |
||
assertEquals(EsQueryExec.class, p.getClass()); | ||
EsQueryExec eqe = (EsQueryExec) p; | ||
assertEquals(1, eqe.output().size()); | ||
assertEquals("LAST(keyword, int)", eqe.output().get(0).qualifiedName()); | ||
assertTrue(eqe.output().get(0).dataType() == DataType.KEYWORD); | ||
assertEquals("LAST(date, int)", eqe.output().get(0).qualifiedName()); | ||
assertTrue(eqe.output().get(0).dataType() == DataType.DATETIME); | ||
assertThat(eqe.queryContainer().aggs().asAggBuilder().toString().replaceAll("\\s+", ""), | ||
endsWith("\"top_hits\":{\"from\":0,\"size\":1,\"version\":false,\"seq_no_primary_term\":false," + | ||
"\"explain\":false,\"docvalue_fields\":[{\"field\":\"keyword\"}]," + | ||
"\"explain\":false,\"docvalue_fields\":[{\"field\":\"date\",\"format\":\"epoch_millis\"}]," + | ||
"\"sort\":[{\"int\":{\"order\":\"desc\",\"missing\":\"_last\",\"unmapped_type\":\"integer\"}}," + | ||
"{\"keyword\":{\"order\":\"desc\",\"missing\":\"_last\",\"unmapped_type\":\"keyword\"}}]}}}}}")); | ||
"{\"date\":{\"order\":\"desc\",\"missing\":\"_last\",\"unmapped_type\":\"date\"}}]}}}}}")); | ||
} | ||
} | ||
} |
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 think a better way would be to ask this parameter for the constructor and add it for each declaration.
So
DATETIME
would be"date"
,INTERVAL_
...null
whileNULL
would be"null"
. Potentially add an overloaded constructor to specify esType name which by default would be the enum name lowercase but with the possibility of being overwritten.