@@ -327,12 +327,13 @@ public void testAliasToInt() throws IOException {
327327 }
328328
329329 public void testFlattenedUnsupported () throws IOException {
330+ assumeOriginalTypesReported ();
330331 new Test ("flattened" ).createIndex ("test" , "flattened" );
331332 index ("test" , """
332333 {"flattened": {"a": "foo"}}""" );
333334 Map <String , Object > result = runEsql ("FROM test* | LIMIT 2" );
334335
335- assertResultMap (result , List .of (columnInfo ("flattened" , "unsupported " )), List .of (matchesList ().item (null )));
336+ assertResultMap (result , List .of (unsupportedColumnInfo ("flattened" , "flattened " )), List .of (matchesList ().item (null )));
336337 }
337338
338339 public void testEmptyMapping () throws IOException {
@@ -689,6 +690,7 @@ public void testByteFieldWithIntSubfieldTooBig() throws IOException {
689690 * </pre>.
690691 */
691692 public void testIncompatibleTypes () throws IOException {
693+ assumeOriginalTypesReported ();
692694 keywordTest ().createIndex ("test1" , "f" );
693695 index ("test1" , """
694696 {"f": "f1"}""" );
@@ -697,7 +699,11 @@ public void testIncompatibleTypes() throws IOException {
697699 {"f": 1}""" );
698700
699701 Map <String , Object > result = runEsql ("FROM test*" );
700- assertResultMap (result , List .of (columnInfo ("f" , "unsupported" )), List .of (matchesList ().item (null ), matchesList ().item (null )));
702+ assertResultMap (
703+ result ,
704+ List .of (unsupportedColumnInfo ("f" , "keyword" , "long" )),
705+ List .of (matchesList ().item (null ), matchesList ().item (null ))
706+ );
701707 ResponseException e = expectThrows (ResponseException .class , () -> runEsql ("FROM test* | SORT f | LIMIT 3" ));
702708 String err = EntityUtils .toString (e .getResponse ().getEntity ());
703709 assertThat (
@@ -758,10 +764,7 @@ public void testDistinctInEachIndex() throws IOException {
758764 * </pre>.
759765 */
760766 public void testMergeKeywordAndObject () throws IOException {
761- assumeTrue (
762- "order of fields in error message inconsistent before 8.14" ,
763- getCachedNodesVersions ().stream ().allMatch (v -> Version .fromString (v ).onOrAfter (Version .V_8_14_0 ))
764- );
767+ assumeOriginalTypesReported ();
765768 keywordTest ().createIndex ("test1" , "file" );
766769 index ("test1" , """
767770 {"file": "f1"}""" );
@@ -797,7 +800,7 @@ public void testMergeKeywordAndObject() throws IOException {
797800 Map <String , Object > result = runEsql ("FROM test* | SORT file.raw | LIMIT 2" );
798801 assertResultMap (
799802 result ,
800- List .of (columnInfo ("file" , "unsupported " ), columnInfo ("file.raw" , "keyword" )),
803+ List .of (unsupportedColumnInfo ("file" , "keyword" , "object " ), columnInfo ("file.raw" , "keyword" )),
801804 List .of (matchesList ().item (null ).item ("o2" ), matchesList ().item (null ).item (null ))
802805 );
803806 }
@@ -817,6 +820,7 @@ public void testMergeKeywordAndObject() throws IOException {
817820 * </pre>.
818821 */
819822 public void testPropagateUnsupportedToSubFields () throws IOException {
823+ assumeOriginalTypesReported ();
820824 createIndex ("test" , index -> {
821825 index .startObject ("properties" );
822826 index .startObject ("f" );
@@ -842,7 +846,7 @@ public void testPropagateUnsupportedToSubFields() throws IOException {
842846 Map <String , Object > result = runEsql ("FROM test* | LIMIT 2" );
843847 assertResultMap (
844848 result ,
845- List .of (columnInfo ("f" , "unsupported " ), columnInfo ("f.raw" , "unsupported " )),
849+ List .of (unsupportedColumnInfo ("f" , "ip_range " ), unsupportedColumnInfo ("f.raw" , "ip_range " )),
846850 List .of (matchesList ().item (null ).item (null ))
847851 );
848852 }
@@ -867,10 +871,7 @@ public void testPropagateUnsupportedToSubFields() throws IOException {
867871 * </pre>.
868872 */
869873 public void testMergeUnsupportedAndObject () throws IOException {
870- assumeTrue (
871- "order of fields in error message inconsistent before 8.14" ,
872- getCachedNodesVersions ().stream ().allMatch (v -> Version .fromString (v ).onOrAfter (Version .V_8_14_0 ))
873- );
874+ assumeOriginalTypesReported ();
874875 createIndex ("test1" , index -> {
875876 index .startObject ("properties" );
876877 index .startObject ("f" ).field ("type" , "ip_range" ).endObject ();
@@ -905,7 +906,7 @@ public void testMergeUnsupportedAndObject() throws IOException {
905906 Map <String , Object > result = runEsql ("FROM test* | LIMIT 2" );
906907 assertResultMap (
907908 result ,
908- List .of (columnInfo ("f" , "unsupported " ), columnInfo ("f.raw" , "unsupported " )),
909+ List .of (unsupportedColumnInfo ("f" , "ip_range " ), unsupportedColumnInfo ("f.raw" , "ip_range " )),
909910 List .of (matchesList ().item (null ).item (null ), matchesList ().item (null ).item (null ))
910911 );
911912 }
@@ -958,10 +959,7 @@ public void testIntegerDocValuesConflict() throws IOException {
958959 * In an ideal world we'd promote the {@code integer} to an {@code long} and just go.
959960 */
960961 public void testLongIntegerConflict () throws IOException {
961- assumeTrue (
962- "order of fields in error message inconsistent before 8.14" ,
963- getCachedNodesVersions ().stream ().allMatch (v -> Version .fromString (v ).onOrAfter (Version .V_8_14_0 ))
964- );
962+ assumeOriginalTypesReported ();
965963 longTest ().sourceMode (SourceMode .DEFAULT ).createIndex ("test1" , "emp_no" );
966964 index ("test1" , """
967965 {"emp_no": 1}""" );
@@ -980,7 +978,11 @@ public void testLongIntegerConflict() throws IOException {
980978 );
981979
982980 Map <String , Object > result = runEsql ("FROM test* | LIMIT 2" );
983- assertResultMap (result , List .of (columnInfo ("emp_no" , "unsupported" )), List .of (matchesList ().item (null ), matchesList ().item (null )));
981+ assertResultMap (
982+ result ,
983+ List .of (unsupportedColumnInfo ("emp_no" , "integer" , "long" )),
984+ List .of (matchesList ().item (null ), matchesList ().item (null ))
985+ );
984986 }
985987
986988 /**
@@ -1000,10 +1002,7 @@ public void testLongIntegerConflict() throws IOException {
10001002 * In an ideal world we'd promote the {@code short} to an {@code integer} and just go.
10011003 */
10021004 public void testIntegerShortConflict () throws IOException {
1003- assumeTrue (
1004- "order of fields in error message inconsistent before 8.14" ,
1005- getCachedNodesVersions ().stream ().allMatch (v -> Version .fromString (v ).onOrAfter (Version .V_8_14_0 ))
1006- );
1005+ assumeOriginalTypesReported ();
10071006 intTest ().sourceMode (SourceMode .DEFAULT ).createIndex ("test1" , "emp_no" );
10081007 index ("test1" , """
10091008 {"emp_no": 1}""" );
@@ -1022,7 +1021,11 @@ public void testIntegerShortConflict() throws IOException {
10221021 );
10231022
10241023 Map <String , Object > result = runEsql ("FROM test* | LIMIT 2" );
1025- assertResultMap (result , List .of (columnInfo ("emp_no" , "unsupported" )), List .of (matchesList ().item (null ), matchesList ().item (null )));
1024+ assertResultMap (
1025+ result ,
1026+ List .of (unsupportedColumnInfo ("emp_no" , "integer" , "short" )),
1027+ List .of (matchesList ().item (null ), matchesList ().item (null ))
1028+ );
10261029 }
10271030
10281031 /**
@@ -1048,10 +1051,7 @@ public void testIntegerShortConflict() throws IOException {
10481051 * </pre>.
10491052 */
10501053 public void testTypeConflictInObject () throws IOException {
1051- assumeTrue (
1052- "order of fields in error message inconsistent before 8.14" ,
1053- getCachedNodesVersions ().stream ().allMatch (v -> Version .fromString (v ).onOrAfter (Version .V_8_14_0 ))
1054- );
1054+ assumeOriginalTypesReported ();
10551055 createIndex ("test1" , empNoInObject ("integer" ));
10561056 index ("test1" , """
10571057 {"foo": {"emp_no": 1}}""" );
@@ -1060,7 +1060,10 @@ public void testTypeConflictInObject() throws IOException {
10601060 {"foo": {"emp_no": "cat"}}""" );
10611061
10621062 Map <String , Object > result = runEsql ("FROM test* | LIMIT 3" );
1063- assertMap (result , getResultMatcher (result ).entry ("columns" , List .of (columnInfo ("foo.emp_no" , "unsupported" ))).extraOk ());
1063+ assertMap (
1064+ result ,
1065+ getResultMatcher (result ).entry ("columns" , List .of (unsupportedColumnInfo ("foo.emp_no" , "integer" , "keyword" ))).extraOk ()
1066+ );
10641067
10651068 ResponseException e = expectThrows (ResponseException .class , () -> runEsql ("FROM test* | SORT foo.emp_no | LIMIT 3" ));
10661069 String err = EntityUtils .toString (e .getResponse ().getEntity ());
@@ -1370,6 +1373,12 @@ private void assumeIndexResolverNestedFieldsNameClashFixed() throws IOException
13701373 );
13711374 }
13721375
1376+ private void assumeOriginalTypesReported () throws IOException {
1377+ var capsName = EsqlCapabilities .Cap .REPORT_ORIGINAL_TYPES .name ().toLowerCase (Locale .ROOT );
1378+ boolean requiredClusterCapability = clusterHasCapability ("POST" , "/_query" , List .of (), List .of (capsName )).orElse (false );
1379+ assumeTrue ("This test makes sense for versions that report original types" , requiredClusterCapability );
1380+ }
1381+
13731382 private CheckedConsumer <XContentBuilder , IOException > empNoInObject (String empNoType ) {
13741383 return index -> {
13751384 index .startObject ("properties" );
@@ -1705,6 +1714,10 @@ private static Map<String, Object> columnInfo(String name, String type) {
17051714 return Map .of ("name" , name , "type" , type );
17061715 }
17071716
1717+ private static Map <String , Object > unsupportedColumnInfo (String name , String ... originalTypes ) {
1718+ return Map .of ("name" , name , "type" , "unsupported" , "original_types" , List .of (originalTypes ));
1719+ }
1720+
17081721 private static void index (String name , String ... docs ) throws IOException {
17091722 Request request = new Request ("POST" , "/" + name + "/_bulk" );
17101723 request .addParameter ("refresh" , "true" );
0 commit comments