Skip to content

Commit 1c1e423

Browse files
authored
Remove test skip after backport (#70890)
This restores SQL's test for fetching `half_floats` after we backported the precision change in that fetch (#70653)
1 parent 3f8a925 commit 1c1e423

File tree

1 file changed

+25
-6
lines changed
  • x-pack/plugin/sql/qa/mixed-node/src/test/java/org/elasticsearch/xpack/sql/qa/mixed_node

1 file changed

+25
-6
lines changed

x-pack/plugin/sql/qa/mixed-node/src/test/java/org/elasticsearch/xpack/sql/qa/mixed_node/SqlSearchIT.java

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package org.elasticsearch.xpack.sql.qa.mixed_node;
99

1010
import org.apache.http.HttpHost;
11+
import org.apache.lucene.document.HalfFloatPoint;
1112
import org.elasticsearch.Version;
1213
import org.elasticsearch.client.Request;
1314
import org.elasticsearch.client.Response;
@@ -94,7 +95,7 @@ public void testAllTypesWithRequestToOldNodes() throws Exception {
9495
columns -> {
9596
columns.add(columnInfo("geo_point_field", "geo_point"));
9697
columns.add(columnInfo("float_field", "float"));
97-
// Until #70653 is backported we won't assert that the half_float is returned with any kind of precision
98+
columns.add(columnInfo("half_float_field", "half_float"));
9899
},
99100
(builder, fieldValues) -> {
100101
Float randomFloat = randomFloat();
@@ -113,9 +114,18 @@ public void testAllTypesWithRequestToOldNodes() throws Exception {
113114
builder.append("\"geo_point_field\":{\"lat\":\"37.386483\", \"lon\":\"-122.083843\"},");
114115
fieldValues.put("geo_point_field", "POINT (-122.083843 37.386483)");
115116
builder.append("\"float_field\":" + randomFloat + ",");
117+
/*
118+
* Double.valueOf(float.toString) gets a `double` representing
119+
* the `float` that we'd get by going through json which is
120+
* base 10. just casting the `float` to a `double` will get
121+
* a lower number with a lot more trailing digits because
122+
* the cast adds *binary* 0s to the end. And those binary
123+
* 0s don't translate the same as json's decimal 0s.
124+
*/
116125
fieldValues.put("float_field", Double.valueOf(Float.valueOf(randomFloat).toString()));
117-
builder.append("\"half_float_field\":\"123.456\"");
118-
// Until #70653 is backported we won't assert that the half_float is returned with any kind of precision
126+
float roundedHalfFloat = HalfFloatPoint.sortableShortToHalfFloat(HalfFloatPoint.halfFloatToSortableShort(randomFloat));
127+
builder.append("\"half_float_field\":\"" + randomFloat + "\"");
128+
fieldValues.put("half_float_field", Double.valueOf(Float.toString(roundedHalfFloat)));
119129
}
120130
}
121131
);
@@ -127,7 +137,7 @@ public void testAllTypesWithRequestToUpgradedNodes() throws Exception {
127137
columns -> {
128138
columns.add(columnInfo("geo_point_field", "geo_point"));
129139
columns.add(columnInfo("float_field", "float"));
130-
// Until #70653 is backported we won't assert that the half_float is returned with any kind of precision
140+
columns.add(columnInfo("half_float_field", "half_float"));
131141
},
132142
(builder, fieldValues) -> {
133143
Float randomFloat = randomFloat();
@@ -143,9 +153,18 @@ public void testAllTypesWithRequestToUpgradedNodes() throws Exception {
143153
builder.append("\"geo_point_field\":{\"lat\":\"37.386483\", \"lon\":\"-122.083843\"},");
144154
fieldValues.put("geo_point_field", "POINT (-122.083843 37.386483)");
145155
builder.append("\"float_field\":" + randomFloat + ",");
156+
/*
157+
* Double.valueOf(float.toString) gets a `double` representing
158+
* the `float` that we'd get by going through json which is
159+
* base 10. just casting the `float` to a `double` will get
160+
* a lower number with a lot more trailing digits because
161+
* the cast adds *binary* 0s to the end. And those binary
162+
* 0s don't translate the same as json's decimal 0s.
163+
*/
146164
fieldValues.put("float_field", Double.valueOf(Float.valueOf(randomFloat).toString()));
147-
builder.append("\"half_float_field\":\"123.456\"");
148-
// Until #70653 is backported we won't assert that the half_float is returned with any kind of precision
165+
float roundedHalfFloat = HalfFloatPoint.sortableShortToHalfFloat(HalfFloatPoint.halfFloatToSortableShort(randomFloat));
166+
builder.append("\"half_float_field\":\"" + randomFloat + "\"");
167+
fieldValues.put("half_float_field", Double.valueOf(Float.toString(roundedHalfFloat)));
149168
}
150169
}
151170
);

0 commit comments

Comments
 (0)