@@ -302,12 +302,13 @@ public void testAliasToInt() throws IOException {
302302 }
303303
304304 public void testFlattenedUnsupported () throws IOException {
305+ assumeOriginalTypesReported ();
305306 new Test ("flattened" ).createIndex ("test" , "flattened" );
306307 index ("test" , """
307308 {"flattened": {"a": "foo"}}""" );
308309 Map <String , Object > result = runEsql ("FROM test* | LIMIT 2" );
309310
310- assertResultMap (result , List .of (columnInfo ("flattened" , "unsupported " )), List .of (matchesList ().item (null )));
311+ assertResultMap (result , List .of (unsupportedColumnInfo ("flattened" , "flattened " )), List .of (matchesList ().item (null )));
311312 }
312313
313314 public void testEmptyMapping () throws IOException {
@@ -664,6 +665,7 @@ public void testByteFieldWithIntSubfieldTooBig() throws IOException {
664665 * </pre>.
665666 */
666667 public void testIncompatibleTypes () throws IOException {
668+ assumeOriginalTypesReported ();
667669 keywordTest ().createIndex ("test1" , "f" );
668670 index ("test1" , """
669671 {"f": "f1"}""" );
@@ -672,7 +674,11 @@ public void testIncompatibleTypes() throws IOException {
672674 {"f": 1}""" );
673675
674676 Map <String , Object > result = runEsql ("FROM test*" );
675- assertResultMap (result , List .of (columnInfo ("f" , "unsupported" )), List .of (matchesList ().item (null ), matchesList ().item (null )));
677+ assertResultMap (
678+ result ,
679+ List .of (unsupportedColumnInfo ("f" , "keyword" , "long" )),
680+ List .of (matchesList ().item (null ), matchesList ().item (null ))
681+ );
676682 ResponseException e = expectThrows (ResponseException .class , () -> runEsql ("FROM test* | SORT f | LIMIT 3" ));
677683 String err = EntityUtils .toString (e .getResponse ().getEntity ());
678684 assertThat (
@@ -733,10 +739,7 @@ public void testDistinctInEachIndex() throws IOException {
733739 * </pre>.
734740 */
735741 public void testMergeKeywordAndObject () throws IOException {
736- assumeTrue (
737- "order of fields in error message inconsistent before 8.14" ,
738- getCachedNodesVersions ().stream ().allMatch (v -> Version .fromString (v ).onOrAfter (Version .V_8_14_0 ))
739- );
742+ assumeOriginalTypesReported ();
740743 keywordTest ().createIndex ("test1" , "file" );
741744 index ("test1" , """
742745 {"file": "f1"}""" );
@@ -772,7 +775,7 @@ public void testMergeKeywordAndObject() throws IOException {
772775 Map <String , Object > result = runEsql ("FROM test* | SORT file.raw | LIMIT 2" );
773776 assertResultMap (
774777 result ,
775- List .of (columnInfo ("file" , "unsupported " ), columnInfo ("file.raw" , "keyword" )),
778+ List .of (unsupportedColumnInfo ("file" , "keyword" , "object " ), columnInfo ("file.raw" , "keyword" )),
776779 List .of (matchesList ().item (null ).item ("o2" ), matchesList ().item (null ).item (null ))
777780 );
778781 }
@@ -792,6 +795,7 @@ public void testMergeKeywordAndObject() throws IOException {
792795 * </pre>.
793796 */
794797 public void testPropagateUnsupportedToSubFields () throws IOException {
798+ assumeOriginalTypesReported ();
795799 createIndex ("test" , index -> {
796800 index .startObject ("properties" );
797801 index .startObject ("f" );
@@ -817,7 +821,7 @@ public void testPropagateUnsupportedToSubFields() throws IOException {
817821 Map <String , Object > result = runEsql ("FROM test* | LIMIT 2" );
818822 assertResultMap (
819823 result ,
820- List .of (columnInfo ("f" , "unsupported " ), columnInfo ("f.raw" , "unsupported " )),
824+ List .of (unsupportedColumnInfo ("f" , "ip_range " ), unsupportedColumnInfo ("f.raw" , "ip_range " )),
821825 List .of (matchesList ().item (null ).item (null ))
822826 );
823827 }
@@ -842,10 +846,7 @@ public void testPropagateUnsupportedToSubFields() throws IOException {
842846 * </pre>.
843847 */
844848 public void testMergeUnsupportedAndObject () throws IOException {
845- assumeTrue (
846- "order of fields in error message inconsistent before 8.14" ,
847- getCachedNodesVersions ().stream ().allMatch (v -> Version .fromString (v ).onOrAfter (Version .V_8_14_0 ))
848- );
849+ assumeOriginalTypesReported ();
849850 createIndex ("test1" , index -> {
850851 index .startObject ("properties" );
851852 index .startObject ("f" ).field ("type" , "ip_range" ).endObject ();
@@ -880,7 +881,7 @@ public void testMergeUnsupportedAndObject() throws IOException {
880881 Map <String , Object > result = runEsql ("FROM test* | LIMIT 2" );
881882 assertResultMap (
882883 result ,
883- List .of (columnInfo ("f" , "unsupported " ), columnInfo ("f.raw" , "unsupported " )),
884+ List .of (unsupportedColumnInfo ("f" , "ip_range " ), unsupportedColumnInfo ("f.raw" , "ip_range " )),
884885 List .of (matchesList ().item (null ).item (null ), matchesList ().item (null ).item (null ))
885886 );
886887 }
@@ -933,10 +934,7 @@ public void testIntegerDocValuesConflict() throws IOException {
933934 * In an ideal world we'd promote the {@code integer} to an {@code long} and just go.
934935 */
935936 public void testLongIntegerConflict () throws IOException {
936- assumeTrue (
937- "order of fields in error message inconsistent before 8.14" ,
938- getCachedNodesVersions ().stream ().allMatch (v -> Version .fromString (v ).onOrAfter (Version .V_8_14_0 ))
939- );
937+ assumeOriginalTypesReported ();
940938 longTest ().sourceMode (SourceMode .DEFAULT ).createIndex ("test1" , "emp_no" );
941939 index ("test1" , """
942940 {"emp_no": 1}""" );
@@ -955,7 +953,11 @@ public void testLongIntegerConflict() throws IOException {
955953 );
956954
957955 Map <String , Object > result = runEsql ("FROM test* | LIMIT 2" );
958- assertResultMap (result , List .of (columnInfo ("emp_no" , "unsupported" )), List .of (matchesList ().item (null ), matchesList ().item (null )));
956+ assertResultMap (
957+ result ,
958+ List .of (unsupportedColumnInfo ("emp_no" , "integer" , "long" )),
959+ List .of (matchesList ().item (null ), matchesList ().item (null ))
960+ );
959961 }
960962
961963 /**
@@ -975,10 +977,7 @@ public void testLongIntegerConflict() throws IOException {
975977 * In an ideal world we'd promote the {@code short} to an {@code integer} and just go.
976978 */
977979 public void testIntegerShortConflict () throws IOException {
978- assumeTrue (
979- "order of fields in error message inconsistent before 8.14" ,
980- getCachedNodesVersions ().stream ().allMatch (v -> Version .fromString (v ).onOrAfter (Version .V_8_14_0 ))
981- );
980+ assumeOriginalTypesReported ();
982981 intTest ().sourceMode (SourceMode .DEFAULT ).createIndex ("test1" , "emp_no" );
983982 index ("test1" , """
984983 {"emp_no": 1}""" );
@@ -997,7 +996,11 @@ public void testIntegerShortConflict() throws IOException {
997996 );
998997
999998 Map <String , Object > result = runEsql ("FROM test* | LIMIT 2" );
1000- assertResultMap (result , List .of (columnInfo ("emp_no" , "unsupported" )), List .of (matchesList ().item (null ), matchesList ().item (null )));
999+ assertResultMap (
1000+ result ,
1001+ List .of (unsupportedColumnInfo ("emp_no" , "integer" , "short" )),
1002+ List .of (matchesList ().item (null ), matchesList ().item (null ))
1003+ );
10011004 }
10021005
10031006 /**
@@ -1023,10 +1026,7 @@ public void testIntegerShortConflict() throws IOException {
10231026 * </pre>.
10241027 */
10251028 public void testTypeConflictInObject () throws IOException {
1026- assumeTrue (
1027- "order of fields in error message inconsistent before 8.14" ,
1028- getCachedNodesVersions ().stream ().allMatch (v -> Version .fromString (v ).onOrAfter (Version .V_8_14_0 ))
1029- );
1029+ assumeOriginalTypesReported ();
10301030 createIndex ("test1" , empNoInObject ("integer" ));
10311031 index ("test1" , """
10321032 {"foo": {"emp_no": 1}}""" );
@@ -1035,7 +1035,10 @@ public void testTypeConflictInObject() throws IOException {
10351035 {"foo": {"emp_no": "cat"}}""" );
10361036
10371037 Map <String , Object > result = runEsql ("FROM test* | LIMIT 3" );
1038- assertMap (result , getResultMatcher (result ).entry ("columns" , List .of (columnInfo ("foo.emp_no" , "unsupported" ))).extraOk ());
1038+ assertMap (
1039+ result ,
1040+ getResultMatcher (result ).entry ("columns" , List .of (unsupportedColumnInfo ("foo.emp_no" , "integer" , "keyword" ))).extraOk ()
1041+ );
10391042
10401043 ResponseException e = expectThrows (ResponseException .class , () -> runEsql ("FROM test* | SORT foo.emp_no | LIMIT 3" ));
10411044 String err = EntityUtils .toString (e .getResponse ().getEntity ());
@@ -1339,6 +1342,12 @@ private void assumeIndexResolverNestedFieldsNameClashFixed() throws IOException
13391342 );
13401343 }
13411344
1345+ private void assumeOriginalTypesReported () throws IOException {
1346+ var capsName = EsqlCapabilities .Cap .REPORT_ORIGINAL_TYPES .name ().toLowerCase (Locale .ROOT );
1347+ boolean requiredClusterCapability = clusterHasCapability ("POST" , "/_query" , List .of (), List .of (capsName )).orElse (false );
1348+ assumeTrue ("This test makes sense for versions that report original types" , requiredClusterCapability );
1349+ }
1350+
13421351 private CheckedConsumer <XContentBuilder , IOException > empNoInObject (String empNoType ) {
13431352 return index -> {
13441353 index .startObject ("properties" );
@@ -1672,6 +1681,10 @@ private static Map<String, Object> columnInfo(String name, String type) {
16721681 return Map .of ("name" , name , "type" , type );
16731682 }
16741683
1684+ private static Map <String , Object > unsupportedColumnInfo (String name , String ... originalTypes ) {
1685+ return Map .of ("name" , name , "type" , "unsupported" , "original_types" , List .of (originalTypes ));
1686+ }
1687+
16751688 private static void index (String name , String ... docs ) throws IOException {
16761689 Request request = new Request ("POST" , "/" + name + "/_bulk" );
16771690 request .addParameter ("refresh" , "true" );
0 commit comments