|
@@ -59,6 +59,7 @@ import java.util.stream.Stream;
|
|
|
|
|
|
import static org.elasticsearch.xpack.sql.expression.function.scalar.math.MathProcessor.MathOperation.E;
|
|
|
import static org.elasticsearch.xpack.sql.expression.function.scalar.math.MathProcessor.MathOperation.PI;
|
|
|
+import static org.hamcrest.CoreMatchers.containsString;
|
|
|
import static org.hamcrest.Matchers.endsWith;
|
|
|
import static org.hamcrest.Matchers.startsWith;
|
|
|
|
|
@@ -728,4 +729,17 @@ public class QueryTranslatorTests extends ESTestCase {
|
|
|
EsQueryExec eqe = (EsQueryExec) p;
|
|
|
assertFalse("Should NOT be tracking hits", eqe.queryContainer().shouldTrackHits());
|
|
|
}
|
|
|
+
|
|
|
+ public void testZonedDateTimeInScripts() throws Exception {
|
|
|
+ PhysicalPlan p = optimizeAndPlan(
|
|
|
+ "SELECT date FROM test WHERE date + INTERVAL 1 YEAR > CAST('2019-03-11T12:34:56.000Z' AS DATETIME)");
|
|
|
+ assertEquals(EsQueryExec.class, p.getClass());
|
|
|
+ EsQueryExec eqe = (EsQueryExec) p;
|
|
|
+ assertThat(eqe.queryContainer().toString().replaceAll("\\s+", ""), containsString(
|
|
|
+ "\"script\":{\"script\":{\"source\":\"InternalSqlScriptUtils.nullSafeFilter("
|
|
|
+ + "InternalSqlScriptUtils.gt(InternalSqlScriptUtils.add(InternalSqlScriptUtils.docValue(doc,params.v0),"
|
|
|
+ + "InternalSqlScriptUtils.intervalYearMonth(params.v1,params.v2)),InternalSqlScriptUtils.asDateTime(params.v3)))\","
|
|
|
+ + "\"lang\":\"painless\","
|
|
|
+ + "\"params\":{\"v0\":\"date\",\"v1\":\"P1Y\",\"v2\":\"INTERVAL_YEAR\",\"v3\":\"2019-03-11T12:34:56.000Z\"}},"));
|
|
|
+ }
|
|
|
}
|