You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2021/08/10 16:43:02 UTC

[GitHub] [solr] thelabdude opened a new pull request #252: SOLR-9853: Improve SQL handling of multi-valued fields: project, group by, where filters

thelabdude opened a new pull request #252:
URL: https://github.com/apache/solr/pull/252


   https://issues.apache.org/jira/browse/SOLR-9853
   
   # Description
   
   WIP ...
   
   # Solution
   
   Please provide a short description of the approach taken to implement your solution.
   
   # Tests
   
   Please describe the tests you've developed or run to confirm this patch implements the feature or solves the problem.
   
   # Checklist
   
   Please review the following and check all that apply:
   
   - [ ] I have reviewed the guidelines for [How to Contribute](https://wiki.apache.org/solr/HowToContribute) and my code conforms to the standards described there to the best of my ability.
   - [ ] I have created a Jira issue and added the issue ID to my pull request title.
   - [ ] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended)
   - [ ] I have developed this patch against the `main` branch.
   - [ ] I have run `./gradlew check`.
   - [ ] I have added tests for my changes.
   - [ ] I have added documentation for the [Reference Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide)
   


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] thelabdude merged pull request #252: SOLR-9853: Ability to project multi-valued fields in SQL query results

Posted by GitBox <gi...@apache.org>.
thelabdude merged pull request #252:
URL: https://github.com/apache/solr/pull/252


   


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] thelabdude commented on a change in pull request #252: SOLR-9853: Improve SQL handling of multi-valued fields: project, group by, where filters

Posted by GitBox <gi...@apache.org>.
thelabdude commented on a change in pull request #252:
URL: https://github.com/apache/solr/pull/252#discussion_r686318203



##########
File path: solr/core/src/java/org/apache/solr/handler/sql/SolrSchema.java
##########
@@ -166,51 +193,54 @@ RelProtoDataType getRelDataType(String collection) {
       }
 
       RelDataType type;
-      switch (luceneFieldType) {
-        case "string":
-          type = typeFactory.createJavaType(String.class);
-          break;
-        case "tint":
-        case "tlong":
-        case "int":
-        case "long":
-        case "pint":
-        case "plong":
-          type = typeFactory.createJavaType(Long.class);
-          break;
-        case "tfloat":
-        case "tdouble":
-        case "float":
-        case "double":
-        case "pfloat":
-        case "pdouble":
-          type = typeFactory.createJavaType(Double.class);
-          break;
-        case "pdate":
-          type = typeFactory.createJavaType(Date.class);
-          break;
-        default:
-          Class<?> javaClass = javaClassForTypeMap.get(luceneFieldType);
-          if (javaClass == null) {
-            javaClass = guessJavaClassForFieldType(schema.getFieldTypeInfo().get(luceneFieldType));
-            javaClassForTypeMap.put(luceneFieldType, javaClass);
-          }
-          type = typeFactory.createJavaType(javaClass);
-      }
 
-      /*
-      EnumSet<FieldFlag> flags = luceneFieldInfo.parseFlags(luceneFieldInfo.getSchema());
-      if(flags != null && flags.contains(FieldFlag.MULTI_VALUED)) {
-        type = typeFactory.createArrayType(type, -1);
+      // We have to pass multi-valued fields through Calcite as SQL Type ANY
+      // Array doesn't work for aggregations! Calcite doesn't like GROUP BY on an ARRAY field
+      // but Solr happily computes aggs on a multi-valued field, so we have a paradigm mis-match and
+      // ANY is the best way to retain use of operators on multi-valued fields while still being able
+      // to GROUP BY and project the multi-valued fields in results
+      EnumSet<FieldFlag> flags = getFieldFlags(luceneFieldInfo);
+      if (flags != null && flags.contains(FieldFlag.MULTI_VALUED)) {
+        type = typeFactory.createSqlType(SqlTypeName.ANY);

Review comment:
       This is the crux of the change for this PR. If multi-valued, then we use type `ANY` which allows us to return multi-valued fields as a List, filter, and group by.




-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] madrob commented on pull request #252: SOLR-9853: Improve SQL handling of multi-valued fields: project, group by, where filters

Posted by GitBox <gi...@apache.org>.
madrob commented on pull request #252:
URL: https://github.com/apache/solr/pull/252#issuecomment-896338823


   Overall looks good, did not run tests. I'd also like to see an extra test where not all of the mv fields have the same values, like where some documents are possibly missing values.


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org