Skip to content

Commit 4fc089b

Browse files
[ES|QL] Date nanos implicit casting in union types option #2 (elastic#127797) (elastic#129004)
* implicit casting for union typed fields mixed with datetime and date_nanos (cherry picked from commit 79e600a) # Conflicts: # x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/RestEsqlIT.java # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java # x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTestUtils.java # x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java # x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LocalPhysicalPlanOptimizerTests.java
1 parent 3ab8e8b commit 4fc089b

File tree

14 files changed

+1333
-12
lines changed

14 files changed

+1333
-12
lines changed

docs/changelog/127797.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 127797
2+
summary: "Date nanos implicit casting in union types option #2"
3+
area: ES|QL
4+
type: enhancement
5+
issues:
6+
- 110009

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/util/DateUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class DateUtils {
6565
.appendValue(MINUTE_OF_HOUR, 2)
6666
.appendLiteral(':')
6767
.appendValue(SECOND_OF_MINUTE, 2)
68-
.appendFraction(NANO_OF_SECOND, 3, 9, true)
68+
.appendFraction(NANO_OF_SECOND, 0, 9, true)
6969
.appendOffsetId()
7070
.toFormatter(Locale.ROOT);
7171

x-pack/plugin/esql/qa/server/single-node/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ dependencies {
77
javaRestTestImplementation project(xpackModule('esql:qa:testFixtures'))
88
javaRestTestImplementation project(xpackModule('esql:qa:server'))
99
javaRestTestImplementation project(xpackModule('esql:tools'))
10+
javaRestTestImplementation project(xpackModule('esql'))
1011
yamlRestTestImplementation project(xpackModule('esql:qa:server'))
1112

1213
javaRestTestImplementation('org.apache.arrow:arrow-vector:16.1.0')

x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestsDataLoader.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public class CsvTestsDataLoader {
105105
);
106106
private static final TestDataset AIRPORTS_WEB = new TestDataset("airports_web");
107107
private static final TestDataset DATE_NANOS = new TestDataset("date_nanos");
108+
private static final TestDataset DATE_NANOS_UNION_TYPES = new TestDataset("date_nanos_union_types");
108109
private static final TestDataset COUNTRIES_BBOX = new TestDataset("countries_bbox");
109110
private static final TestDataset COUNTRIES_BBOX_WEB = new TestDataset("countries_bbox_web");
110111
private static final TestDataset AIRPORT_CITY_BOUNDARIES = new TestDataset("airport_city_boundaries");
@@ -163,6 +164,7 @@ public class CsvTestsDataLoader {
163164
Map.entry(MULTIVALUE_GEOMETRIES.indexName, MULTIVALUE_GEOMETRIES),
164165
Map.entry(MULTIVALUE_POINTS.indexName, MULTIVALUE_POINTS),
165166
Map.entry(DATE_NANOS.indexName, DATE_NANOS),
167+
Map.entry(DATE_NANOS_UNION_TYPES.indexName, DATE_NANOS_UNION_TYPES),
166168
Map.entry(K8S.indexName, K8S),
167169
Map.entry(DISTANCES.indexName, DISTANCES),
168170
Map.entry(ADDRESSES.indexName, ADDRESSES),
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
millis:date_nanos,nanos:date,num:long
2+
2023-10-23T13:55:01.543123456Z,2023-10-23T13:55:01.543Z,1698069301543123456
3+
2023-10-23T13:55:01.543123456Z,2023-10-23T13:55:01.543Z,1698069301543123456
4+
2023-10-23T13:53:55.832987654Z,2023-10-23T13:53:55.832Z,1698069235832987654
5+
2023-10-23T13:52:55.015787878Z,2023-10-23T13:52:55.015Z,1698069175015787878
6+
2023-10-23T13:51:54.732102837Z,2023-10-23T13:51:54.732Z,1698069114732102837
7+
2023-10-23T13:33:34.937193000Z,2023-10-23T13:33:34.937Z,1698068014937193000
8+
2023-10-23T12:27:28.948000000Z,2023-10-23T12:27:28.948Z,1698064048948000000
9+
2023-10-23T12:15:03.360103847Z,2023-10-23T12:15:03.360Z,1698063303360103847
10+
2023-10-23T12:15:03.360103847Z,2023-10-23T12:15:03.360Z,1698063303360103847
11+
1999-10-23T12:15:03.360103847Z,[2023-03-23T12:15:03.360Z, 2023-02-23T13:33:34.937Z, 2023-01-23T13:55:01.543Z], 0
12+
1999-10-22T12:15:03.360103847Z,[2023-03-23T12:15:03.360Z, 2023-03-23T12:15:03.360Z, 2023-03-23T12:15:03.360Z], 0
13+
2023-10-23T12:15:03.360103847Z,1923-10-23T12:15:03.360Z,1698063303360103847

x-pack/plugin/esql/qa/testFixtures/src/main/resources/data/employees_incompatible.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
birth_date:date_nanos ,emp_no:long,first_name:text,gender:text,hire_date:date_nanos,languages:byte,languages.long:long,languages.short:short,languages.byte:byte,last_name:text,salary:long,height:float,height.double:double,height.scaled_float:scaled_float,height.half_float:half_float,still_hired:keyword,avg_worked_seconds:unsigned_long,job_positions:text,is_rehired:keyword,salary_change:float,salary_change.int:integer,salary_change.long:long,salary_change.keyword:keyword
1+
birth_date:date ,emp_no:long,first_name:text,gender:text,hire_date:date_nanos,languages:byte,languages.long:long,languages.short:short,languages.byte:byte,last_name:text,salary:long,height:float,height.double:double,height.scaled_float:scaled_float,height.half_float:half_float,still_hired:keyword,avg_worked_seconds:unsigned_long,job_positions:text,is_rehired:keyword,salary_change:float,salary_change.int:integer,salary_change.long:long,salary_change.keyword:keyword
22
1953-09-02T00:00:00Z,10001,Georgi ,M,1986-06-26T00:00:00Z,2,2,2,2,Facello ,57305,2.03,2.03,2.03,2.03,true ,268728049,[Senior Python Developer,Accountant],[false,true],[1.19],[1],[1],[1.19]
33
1964-06-02T00:00:00Z,10002,Bezalel ,F,1985-11-21T00:00:00Z,5,5,5,5,Simmel ,56371,2.08,2.08,2.08,2.08,true ,328922887,[Senior Team Lead],[false,false],[-7.23,11.17],[-7,11],[-7,11],[-7.23,11.17]
44
1959-12-03T00:00:00Z,10003,Parto ,M,1986-08-28T00:00:00Z,4,4,4,4,Bamford ,61805,1.83,1.83,1.83,1.83,false,200296405,[],[],[14.68,12.82],[14,12],[14,12],[14.68,12.82]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"properties": {
3+
"millis": {
4+
"type": "date_nanos"
5+
},
6+
"nanos": {
7+
"type": "date"
8+
},
9+
"num": {
10+
"type": "long"
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)