thelabdude commented on pull request #177:
URL: https://github.com/apache/solr/pull/177#issuecomment-866998624
The test failure is because Calcite's expression reducer rules is removing
the second part of the AND statement b/c it looks unnecessary to Calcite. From
the debug:
```
rel#718:LogicalFilter.NONE.[](input=RelSubset#699,condition==(CAST($0):VARCHAR,
'XXXX'))
call#7692 rule [ReduceExpressionsRule(Filter)]
rel#700:LogicalFilter.NONE.[](input=RelSubset#699,condition=AND(=(CAST($0):VARCHAR,
'XXXX'), <>(CAST($0):VARCHAR, 'XXXY')))
no parent
```
See how the expression gets "reduced" to `(CAST($0):VARCHAR, 'XXXX'))`. This
is because Calcite doesn't know about search engine semantics. Personally, I
think the issue here is mapping the `=` operator to a term match in an analyzed
text field vs. real equality.
These changes fix the breakage:
```
diff --git a/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java
b/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java
index 60990c07e19..5a1f9c4a1fa 100644
--- a/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java
+++ b/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java
@@ -1167,7 +1167,7 @@ public class TestSQLHandler extends SolrCloudTestCase {
sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
"stmt", "select str_s, count(*), sum(field_i), min(field_i),
max(field_i), "
- + "cast(avg(1.0 * field_i) as float) from collection1 where
(text_t='XXXX' AND NOT (text_t='XXXY')) "
+ + "cast(avg(1.0 * field_i) as float) from collection1 where
(text_t LIKE 'XXXX' AND NOT (text_t LIKE 'XXXY')) "
+ "group by str_s order by str_s desc");
tuples = getTuples(sParams, baseUrl);
@@ -1203,7 +1203,7 @@ public class TestSQLHandler extends SolrCloudTestCase {
sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
"stmt", "select str_s as myString, count(*), sum(field_i) as mySum,
min(field_i), max(field_i), "
- + "cast(avg(1.0 * field_i) as float) from collection1 where
(text_t='XXXX' AND NOT (text_t='XXXY')) "
+ + "cast(avg(1.0 * field_i) as float) from collection1 where
(text_t LIKE 'XXXX' AND NOT (text_t LIKE 'XXXY')) "
+ "group by str_s order by myString desc");
tuples = getTuples(sParams, baseUrl);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]