Skip to content

Commit 094c98f

Browse files
More cleanup, remove rule
1 parent e56aab3 commit 094c98f

File tree

4 files changed

+4
-68
lines changed

4 files changed

+4
-68
lines changed

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Literal.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ public Literal(Source source, Object value, DataType dataType) {
5353
super(source);
5454
assert noPlainStrings(value, dataType);
5555
this.dataType = dataType;
56-
this.value = stringsToBytesRef(dataType, value);
56+
this.value = value;
5757
}
5858

5959
private boolean noPlainStrings(Object value, DataType dataType) {
60-
if (dataType == KEYWORD || dataType == TEXT) {
60+
if (dataType == KEYWORD || dataType == TEXT || dataType == VERSION) {
6161
if (value instanceof String) {
6262
return false;
6363
}
@@ -68,19 +68,6 @@ private boolean noPlainStrings(Object value, DataType dataType) {
6868
return true;
6969
}
7070

71-
@SuppressWarnings({ "unchecked", "rawtypes" })
72-
private static Object stringsToBytesRef(DataType dataType, Object value) {
73-
// we should do it for IPs as well, but there is a problem for CIDR_MATCH, see CombineDisjunctions
74-
if (value instanceof String s && dataType == VERSION) {
75-
return new Version(s).toBytesRef();
76-
}
77-
78-
if (value instanceof List l) {
79-
return l.stream().map(x -> stringsToBytesRef(dataType, x)).toList();
80-
}
81-
return value;
82-
}
83-
8471
private static Literal readFrom(StreamInput in) throws IOException {
8572
Source source = Source.readFrom((StreamInput & PlanStreamInput) in);
8673
Object value = in.readGenericValue();
@@ -196,9 +183,7 @@ public static Literal of(FoldContext ctx, Expression foldable) {
196183
}
197184

198185
public static Literal of(Expression source, Object value) {
199-
DataType type = source.dataType();
200-
value = stringsToBytesRef(type, value);
201-
return new Literal(source.source(), value, type);
186+
return new Literal(source.source(), value, source.dataType());
202187
}
203188

204189
/**

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizer.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.elasticsearch.xpack.esql.optimizer.rules.logical.CombineEvals;
1818
import org.elasticsearch.xpack.esql.optimizer.rules.logical.CombineProjections;
1919
import org.elasticsearch.xpack.esql.optimizer.rules.logical.ConstantFolding;
20-
import org.elasticsearch.xpack.esql.optimizer.rules.logical.ConvertStringToByteRef;
2120
import org.elasticsearch.xpack.esql.optimizer.rules.logical.ExtractAggregateCommonFilter;
2221
import org.elasticsearch.xpack.esql.optimizer.rules.logical.FoldNull;
2322
import org.elasticsearch.xpack.esql.optimizer.rules.logical.LiteralsOnTheRight;
@@ -167,7 +166,6 @@ protected static Batch<LogicalPlan> operators() {
167166
new CombineEvals(),
168167
new PruneEmptyPlans(),
169168
new PropagateEmptyRelation(),
170-
new ConvertStringToByteRef(),
171169
new FoldNull(),
172170
new SplitInWithFoldableValue(),
173171
new PropagateEvalFoldables(),

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/ConvertStringToByteRef.java

Lines changed: 0 additions & 47 deletions
This file was deleted.

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ public PlanFactory visitSampleCommand(EsqlBaseParser.SampleCommandContext ctx) {
797797
} else {
798798
throw new ParsingException(
799799
source(ctx),
800-
"invalid value for SAMPLE probability [" + val + "], expecting a number between 0 and 1, exclusive"
800+
"invalid value for SAMPLE probability [" + BytesRefs.toString(val) + "], expecting a number between 0 and 1, exclusive"
801801
);
802802
}
803803
}

0 commit comments

Comments
 (0)