SQL: [Tests] Add tests for fixed issues (#52335)
Add tests to verify behaviour for fixed issues: #33724 & #38306 (cherry picked from commit 89fb6753a9db9484a5622417cd4ffea9af0347ad)
This commit is contained in:
parent
6cd42923d5
commit
51e74be1bb
|
@ -534,6 +534,19 @@ SELECT HISTOGRAM(YEAR(birth_date), 2) AS h, COUNT(*) as c FROM test_emp GROUP BY
|
|||
null |10
|
||||
;
|
||||
|
||||
histogramDateTimeWithScalars
|
||||
schema::h:ts|c:l
|
||||
SELECT HISTOGRAM(birth_date, INTERVAL 20 MONTHS + INTERVAL 30 MONTHS) AS h, COUNT(*) as c FROM test_emp GROUP BY h ORDER BY c DESC;
|
||||
|
||||
h | c
|
||||
------------------------+---------------
|
||||
1957-09-06T00:00:00.000Z|31
|
||||
1953-07-29T00:00:00.000Z|24
|
||||
1961-10-15T00:00:00.000Z|20
|
||||
1949-06-20T00:00:00.000Z|15
|
||||
null |10
|
||||
;
|
||||
|
||||
histogramYearOnDateTimeWithScalars
|
||||
schema::year:i|c:l
|
||||
SELECT YEAR(CAST(birth_date + INTERVAL 5 YEARS AS DATE) + INTERVAL 20 MONTHS) AS year, COUNT(*) as c FROM test_emp GROUP BY 1;
|
||||
|
|
|
@ -457,6 +457,8 @@ public class VerifierErrorMessagesTests extends ESTestCase {
|
|||
public void testGroupByAggregate() {
|
||||
assertEquals("1:36: Cannot use an aggregate [AVG] for grouping",
|
||||
error("SELECT AVG(int) FROM test GROUP BY AVG(int)"));
|
||||
assertEquals("1:65: Cannot use an aggregate [AVG] for grouping",
|
||||
error("SELECT ROUND(AVG(int),2), AVG(int), COUNT(*) FROM test GROUP BY AVG(int) ORDER BY AVG(int)"));
|
||||
}
|
||||
|
||||
public void testStarOnNested() {
|
||||
|
|
|
@ -997,6 +997,21 @@ public class QueryTranslatorTests extends ESTestCase {
|
|||
+ "\"fixed_interval\":\"62208000000ms\",\"time_zone\":\"Z\"}}}]}"));
|
||||
}
|
||||
|
||||
public void testGroupByHistogramWithScalarsQueryTranslator() {
|
||||
PhysicalPlan p = optimizeAndPlan("SELECT MAX(int), HISTOGRAM(date, INTERVAL 5 YEARS - INTERVAL 6 MONTHS) AS h " +
|
||||
"FROM test GROUP BY h");
|
||||
assertEquals(EsQueryExec.class, p.getClass());
|
||||
EsQueryExec eqe = (EsQueryExec) p;
|
||||
assertEquals(2, eqe.output().size());
|
||||
assertEquals("MAX(int)", eqe.output().get(0).qualifiedName());
|
||||
assertEquals(INTEGER, eqe.output().get(0).dataType());
|
||||
assertEquals("h", eqe.output().get(1).qualifiedName());
|
||||
assertEquals(DATETIME, eqe.output().get(1).dataType());
|
||||
assertThat(eqe.queryContainer().aggs().asAggBuilder().toString().replaceAll("\\s+", ""),
|
||||
containsString("\"date_histogram\":{\"field\":\"date\",\"missing_bucket\":true,\"value_type\":\"date\"," +
|
||||
"\"order\":\"asc\",\"fixed_interval\":\"139968000000ms\",\"time_zone\":\"Z\"}}}]}"));
|
||||
}
|
||||
|
||||
public void testGroupByYearQueryTranslator() {
|
||||
PhysicalPlan p = optimizeAndPlan("SELECT YEAR(date) FROM test GROUP BY YEAR(date)");
|
||||
assertEquals(EsQueryExec.class, p.getClass());
|
||||
|
|
Loading…
Reference in New Issue