mirror of https://github.com/apache/lucene.git
SOLR-8530: Add support for aggregate HAVING comparisons without single quotes
This commit is contained in:
parent
a810fb3234
commit
b32cd82318
|
@ -54,7 +54,7 @@ public class EqualsOperation extends LeafOperation {
|
|||
|
||||
public StreamExpression toExpression(StreamFactory factory) throws IOException {
|
||||
StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
|
||||
expression.addParameter(quote(field));
|
||||
expression.addParameter(field);
|
||||
expression.addParameter(Double.toString(val));
|
||||
return expression;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class GreaterThanEqualToOperation extends LeafOperation {
|
|||
|
||||
public StreamExpression toExpression(StreamFactory factory) throws IOException {
|
||||
StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
|
||||
expression.addParameter(quote(field));
|
||||
expression.addParameter(field);
|
||||
expression.addParameter(Double.toString(val));
|
||||
return expression;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class GreaterThanOperation extends LeafOperation {
|
|||
|
||||
public StreamExpression toExpression(StreamFactory factory) throws IOException {
|
||||
StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
|
||||
expression.addParameter(quote(field));
|
||||
expression.addParameter(field);
|
||||
expression.addParameter(Double.toString(val));
|
||||
return expression;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,6 @@ public abstract class LeafOperation implements BooleanOperation {
|
|||
|
||||
public LeafOperation(StreamExpression expression, StreamFactory factory) throws IOException {
|
||||
this.field = factory.getValueOperand(expression, 0);
|
||||
this.field = this.field.replace("'","");
|
||||
this.val = Double.parseDouble(factory.getValueOperand(expression, 1));
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public class LessThanEqualToOperation extends LeafOperation {
|
|||
|
||||
public StreamExpression toExpression(StreamFactory factory) throws IOException {
|
||||
StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
|
||||
expression.addParameter(quote(field));
|
||||
expression.addParameter(field);
|
||||
expression.addParameter(Double.toString(val));
|
||||
return expression;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class LessThanOperation extends LeafOperation {
|
|||
|
||||
public StreamExpression toExpression(StreamFactory factory) throws IOException {
|
||||
StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
|
||||
expression.addParameter(quote(field));
|
||||
expression.addParameter(field);
|
||||
expression.addParameter(Double.toString(val));
|
||||
return expression;
|
||||
}
|
||||
|
|
|
@ -93,6 +93,8 @@ public class StreamFactory implements Serializable {
|
|||
if(null != parameter){
|
||||
if(parameter instanceof StreamExpressionValue){
|
||||
return ((StreamExpressionValue)parameter).getValue();
|
||||
} else if(parameter instanceof StreamExpression) {
|
||||
return parameter.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -915,14 +915,13 @@ public class StreamExpressionTest extends SolrCloudTestCase {
|
|||
assertTrue(t.getString("id").equals("9"));
|
||||
|
||||
|
||||
stream = factory.constructStream("having(rollup(over=a_f, sum(a_i), search(" + COLLECTIONORALIAS + ", q=*:*, fl=\"id,a_s,a_i,a_f\", sort=\"a_f asc\")), eq('sum(a_i)', 9))");
|
||||
stream = factory.constructStream("having(rollup(over=a_f, sum(a_i), search(" + COLLECTIONORALIAS + ", q=*:*, fl=\"id,a_s,a_i,a_f\", sort=\"a_f asc\")), and(eq(sum(a_i), 9),eq(sum(a_i), 9)))");
|
||||
context = new StreamContext();
|
||||
context.setSolrClientCache(solrClientCache);
|
||||
stream.setStreamContext(context);
|
||||
tuples = getTuples(stream);
|
||||
|
||||
assert(tuples.size() == 1);
|
||||
|
||||
t = tuples.get(0);
|
||||
assertTrue(t.getDouble("a_f") == 10.0D);
|
||||
|
||||
|
@ -1024,7 +1023,7 @@ public class StreamExpressionTest extends SolrCloudTestCase {
|
|||
t = tuples.get(1);
|
||||
assertTrue(t.getString("id").equals("9"));
|
||||
|
||||
stream = factory.constructStream("parallel("+COLLECTIONORALIAS+", workers=2, sort=\"a_f asc\", having(rollup(over=a_f, sum(a_i), search(" + COLLECTIONORALIAS + ", q=*:*, fl=\"id,a_s,a_i,a_f\", sort=\"a_f asc\", partitionKeys=a_f)), eq('sum(a_i)', 9)))");
|
||||
stream = factory.constructStream("parallel("+COLLECTIONORALIAS+", workers=2, sort=\"a_f asc\", having(rollup(over=a_f, sum(a_i), search(" + COLLECTIONORALIAS + ", q=*:*, fl=\"id,a_s,a_i,a_f\", sort=\"a_f asc\", partitionKeys=a_f)), and(eq(sum(a_i), 9),eq(sum(a_i),9))))");
|
||||
context = new StreamContext();
|
||||
context.setSolrClientCache(solrClientCache);
|
||||
stream.setStreamContext(context);
|
||||
|
|
Loading…
Reference in New Issue