@@ -323,12 +323,13 @@ public void testAliasToInt() throws IOException {
323323 }
324324
325325 public void testFlattenedUnsupported () throws IOException {
326+ assumeOriginalTypesReported ();
326327 new Test ("flattened" ).createIndex ("test" , "flattened" );
327328 index ("test" , """
328329 {"flattened": {"a": "foo"}}""" );
329330 Map <String , Object > result = runEsql ("FROM test* | LIMIT 2" );
330331
331- assertResultMap (result , List .of (columnInfo ("flattened" , "unsupported " )), List .of (matchesList ().item (null )));
332+ assertResultMap (result , List .of (unsupportedColumnInfo ("flattened" , "flattened " )), List .of (matchesList ().item (null )));
332333 }
333334
334335 public void testEmptyMapping () throws IOException {
@@ -685,6 +686,7 @@ public void testByteFieldWithIntSubfieldTooBig() throws IOException {
685686 * </pre>.
686687 */
687688 public void testIncompatibleTypes () throws IOException {
689+ assumeOriginalTypesReported ();
688690 keywordTest ().createIndex ("test1" , "f" );
689691 index ("test1" , """
690692 {"f": "f1"}""" );
@@ -693,7 +695,11 @@ public void testIncompatibleTypes() throws IOException {
693695 {"f": 1}""" );
694696
695697 Map <String , Object > result = runEsql ("FROM test*" );
696- assertResultMap (result , List .of (columnInfo ("f" , "unsupported" )), List .of (matchesList ().item (null ), matchesList ().item (null )));
698+ assertResultMap (
699+ result ,
700+ List .of (unsupportedColumnInfo ("f" , "keyword" , "long" )),
701+ List .of (matchesList ().item (null ), matchesList ().item (null ))
702+ );
697703 ResponseException e = expectThrows (ResponseException .class , () -> runEsql ("FROM test* | SORT f | LIMIT 3" ));
698704 String err = EntityUtils .toString (e .getResponse ().getEntity ());
699705 assertThat (
@@ -754,10 +760,7 @@ public void testDistinctInEachIndex() throws IOException {
754760 * </pre>.
755761 */
756762 public void testMergeKeywordAndObject () throws IOException {
757- assumeTrue (
758- "order of fields in error message inconsistent before 8.14" ,
759- getCachedNodesVersions ().stream ().allMatch (v -> Version .fromString (v ).onOrAfter (Version .V_8_14_0 ))
760- );
763+ assumeOriginalTypesReported ();
761764 keywordTest ().createIndex ("test1" , "file" );
762765 index ("test1" , """
763766 {"file": "f1"}""" );
@@ -793,7 +796,7 @@ public void testMergeKeywordAndObject() throws IOException {
793796 Map <String , Object > result = runEsql ("FROM test* | SORT file.raw | LIMIT 2" );
794797 assertResultMap (
795798 result ,
796- List .of (columnInfo ("file" , "unsupported " ), columnInfo ("file.raw" , "keyword" )),
799+ List .of (unsupportedColumnInfo ("file" , "keyword" , "object " ), columnInfo ("file.raw" , "keyword" )),
797800 List .of (matchesList ().item (null ).item ("o2" ), matchesList ().item (null ).item (null ))
798801 );
799802 }
@@ -813,6 +816,7 @@ public void testMergeKeywordAndObject() throws IOException {
813816 * </pre>.
814817 */
815818 public void testPropagateUnsupportedToSubFields () throws IOException {
819+ assumeOriginalTypesReported ();
816820 createIndex ("test" , index -> {
817821 index .startObject ("properties" );
818822 index .startObject ("f" );
@@ -838,7 +842,7 @@ public void testPropagateUnsupportedToSubFields() throws IOException {
838842 Map <String , Object > result = runEsql ("FROM test* | LIMIT 2" );
839843 assertResultMap (
840844 result ,
841- List .of (columnInfo ("f" , "unsupported " ), columnInfo ("f.raw" , "unsupported " )),
845+ List .of (unsupportedColumnInfo ("f" , "ip_range " ), unsupportedColumnInfo ("f.raw" , "ip_range " )),
842846 List .of (matchesList ().item (null ).item (null ))
843847 );
844848 }
@@ -863,10 +867,7 @@ public void testPropagateUnsupportedToSubFields() throws IOException {
863867 * </pre>.
864868 */
865869 public void testMergeUnsupportedAndObject () throws IOException {
866- assumeTrue (
867- "order of fields in error message inconsistent before 8.14" ,
868- getCachedNodesVersions ().stream ().allMatch (v -> Version .fromString (v ).onOrAfter (Version .V_8_14_0 ))
869- );
870+ assumeOriginalTypesReported ();
870871 createIndex ("test1" , index -> {
871872 index .startObject ("properties" );
872873 index .startObject ("f" ).field ("type" , "ip_range" ).endObject ();
@@ -901,7 +902,7 @@ public void testMergeUnsupportedAndObject() throws IOException {
901902 Map <String , Object > result = runEsql ("FROM test* | LIMIT 2" );
902903 assertResultMap (
903904 result ,
904- List .of (columnInfo ("f" , "unsupported " ), columnInfo ("f.raw" , "unsupported " )),
905+ List .of (unsupportedColumnInfo ("f" , "ip_range " ), unsupportedColumnInfo ("f.raw" , "ip_range " )),
905906 List .of (matchesList ().item (null ).item (null ), matchesList ().item (null ).item (null ))
906907 );
907908 }
@@ -954,10 +955,7 @@ public void testIntegerDocValuesConflict() throws IOException {
954955 * In an ideal world we'd promote the {@code integer} to an {@code long} and just go.
955956 */
956957 public void testLongIntegerConflict () throws IOException {
957- assumeTrue (
958- "order of fields in error message inconsistent before 8.14" ,
959- getCachedNodesVersions ().stream ().allMatch (v -> Version .fromString (v ).onOrAfter (Version .V_8_14_0 ))
960- );
958+ assumeOriginalTypesReported ();
961959 longTest ().sourceMode (SourceMode .DEFAULT ).createIndex ("test1" , "emp_no" );
962960 index ("test1" , """
963961 {"emp_no": 1}""" );
@@ -976,7 +974,11 @@ public void testLongIntegerConflict() throws IOException {
976974 );
977975
978976 Map <String , Object > result = runEsql ("FROM test* | LIMIT 2" );
979- assertResultMap (result , List .of (columnInfo ("emp_no" , "unsupported" )), List .of (matchesList ().item (null ), matchesList ().item (null )));
977+ assertResultMap (
978+ result ,
979+ List .of (unsupportedColumnInfo ("emp_no" , "integer" , "long" )),
980+ List .of (matchesList ().item (null ), matchesList ().item (null ))
981+ );
980982 }
981983
982984 /**
@@ -996,10 +998,7 @@ public void testLongIntegerConflict() throws IOException {
996998 * In an ideal world we'd promote the {@code short} to an {@code integer} and just go.
997999 */
9981000 public void testIntegerShortConflict () throws IOException {
999- assumeTrue (
1000- "order of fields in error message inconsistent before 8.14" ,
1001- getCachedNodesVersions ().stream ().allMatch (v -> Version .fromString (v ).onOrAfter (Version .V_8_14_0 ))
1002- );
1001+ assumeOriginalTypesReported ();
10031002 intTest ().sourceMode (SourceMode .DEFAULT ).createIndex ("test1" , "emp_no" );
10041003 index ("test1" , """
10051004 {"emp_no": 1}""" );
@@ -1018,7 +1017,11 @@ public void testIntegerShortConflict() throws IOException {
10181017 );
10191018
10201019 Map <String , Object > result = runEsql ("FROM test* | LIMIT 2" );
1021- assertResultMap (result , List .of (columnInfo ("emp_no" , "unsupported" )), List .of (matchesList ().item (null ), matchesList ().item (null )));
1020+ assertResultMap (
1021+ result ,
1022+ List .of (unsupportedColumnInfo ("emp_no" , "integer" , "short" )),
1023+ List .of (matchesList ().item (null ), matchesList ().item (null ))
1024+ );
10221025 }
10231026
10241027 /**
@@ -1044,10 +1047,7 @@ public void testIntegerShortConflict() throws IOException {
10441047 * </pre>.
10451048 */
10461049 public void testTypeConflictInObject () throws IOException {
1047- assumeTrue (
1048- "order of fields in error message inconsistent before 8.14" ,
1049- getCachedNodesVersions ().stream ().allMatch (v -> Version .fromString (v ).onOrAfter (Version .V_8_14_0 ))
1050- );
1050+ assumeOriginalTypesReported ();
10511051 createIndex ("test1" , empNoInObject ("integer" ));
10521052 index ("test1" , """
10531053 {"foo": {"emp_no": 1}}""" );
@@ -1056,7 +1056,10 @@ public void testTypeConflictInObject() throws IOException {
10561056 {"foo": {"emp_no": "cat"}}""" );
10571057
10581058 Map <String , Object > result = runEsql ("FROM test* | LIMIT 3" );
1059- assertMap (result , getResultMatcher (result ).entry ("columns" , List .of (columnInfo ("foo.emp_no" , "unsupported" ))).extraOk ());
1059+ assertMap (
1060+ result ,
1061+ getResultMatcher (result ).entry ("columns" , List .of (unsupportedColumnInfo ("foo.emp_no" , "integer" , "keyword" ))).extraOk ()
1062+ );
10601063
10611064 ResponseException e = expectThrows (ResponseException .class , () -> runEsql ("FROM test* | SORT foo.emp_no | LIMIT 3" ));
10621065 String err = EntityUtils .toString (e .getResponse ().getEntity ());
@@ -1366,6 +1369,12 @@ private void assumeIndexResolverNestedFieldsNameClashFixed() throws IOException
13661369 );
13671370 }
13681371
1372+ private void assumeOriginalTypesReported () throws IOException {
1373+ var capsName = EsqlCapabilities .Cap .REPORT_ORIGINAL_TYPES .name ().toLowerCase (Locale .ROOT );
1374+ boolean requiredClusterCapability = clusterHasCapability ("POST" , "/_query" , List .of (), List .of (capsName )).orElse (false );
1375+ assumeTrue ("This test makes sense for versions that report original types" , requiredClusterCapability );
1376+ }
1377+
13691378 private CheckedConsumer <XContentBuilder , IOException > empNoInObject (String empNoType ) {
13701379 return index -> {
13711380 index .startObject ("properties" );
@@ -1701,6 +1710,10 @@ private static Map<String, Object> columnInfo(String name, String type) {
17011710 return Map .of ("name" , name , "type" , type );
17021711 }
17031712
1713+ private static Map <String , Object > unsupportedColumnInfo (String name , String ... originalTypes ) {
1714+ return Map .of ("name" , name , "type" , "unsupported" , "original_types" , List .of (originalTypes ));
1715+ }
1716+
17041717 private static void index (String name , String ... docs ) throws IOException {
17051718 Request request = new Request ("POST" , "/" + name + "/_bulk" );
17061719 request .addParameter ("refresh" , "true" );
0 commit comments