-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Value type hint as string #80838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Value type hint as string #80838
Changes from all commits
91cd7f8
d4a818a
9d39d8b
f642826
669381f
188cad9
c3d4bb6
fb42a7c
33bf6ff
d9a991f
c26b1a8
9f202a9
5811cff
d7ea0d5
659e0aa
aca10ba
1f9fe33
78fdad5
099f086
f4fa34d
62cdfdf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,9 @@ public abstract class ArrayValuesSourceParser<VS extends ValuesSource> implement | |
|
||
public abstract static class NumericValuesSourceParser extends ArrayValuesSourceParser<ValuesSource.Numeric> { | ||
|
||
// TODO: Long Support? IDK what we should do here. | ||
protected NumericValuesSourceParser(boolean formattable) { | ||
super(formattable, CoreValuesSourceType.NUMERIC, ValueType.NUMERIC); | ||
super(formattable, CoreValuesSourceType.DOUBLE, ValueType.NUMERIC); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's probably best not to drop support for anything in a big refactoring PR. Maybe make sure we have a test that targets a |
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,6 @@ | |
import org.elasticsearch.search.aggregations.support.ValueType; | ||
import org.elasticsearch.search.builder.SearchSourceBuilder; | ||
import org.elasticsearch.test.ESIntegTestCase; | ||
import org.elasticsearch.xcontent.XContentParseException; | ||
import org.elasticsearch.xcontent.XContentParser; | ||
import org.elasticsearch.xcontent.json.JsonXContent; | ||
import org.junit.After; | ||
|
@@ -1389,16 +1388,20 @@ public void testScriptWithValueType() throws Exception { | |
assertThat(terms.getBuckets().size(), equalTo(1)); | ||
} | ||
|
||
String invalidValueType = source.replaceAll("\"value_type\":\"n.*\"", "\"value_type\":\"foobar\""); | ||
String invalidValueType = source.replaceAll("\"value_type\":\"n.*?\"", "\"value_type\":\"foobar\""); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regexes are hard. This test has always produced invalid json here, but apparently in the old code path we failed on value type validation first. Stream parsing I guess. |
||
|
||
try (XContentParser parser = createParser(JsonXContent.jsonXContent, invalidValueType)) { | ||
XContentParseException ex = expectThrows( | ||
XContentParseException.class, | ||
SearchPhaseExecutionException ex = expectThrows( | ||
SearchPhaseExecutionException.class, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We no longer catch invalid value types at parse time. We do still catch them before aggregation execution though (at ValuesSourceConfig#Resolve time). |
||
() -> client().prepareSearch("idx").setSource(SearchSourceBuilder.fromXContent(parser)).get() | ||
); | ||
assertThat(ex.getCause(), instanceOf(IllegalArgumentException.class)); | ||
|
||
assertThat(ex.getCause(), instanceOf(ElasticsearchException.class)); | ||
assertThat(ex.getCause().getMessage(), containsString("Unknown value type [foobar]")); | ||
|
||
assertThat(ex.getCause().getCause(), instanceOf(IllegalArgumentException.class)); | ||
assertThat(ex.getCause().getCause().getMessage(), containsString("Unknown value type [foobar]")); | ||
|
||
} | ||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this one also want to have
double
here?