Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-9372

Different data types returned depending on the aggregation mode used to execute a SQL statement

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.1
    • Fix Version/s: 6.5.1
    • Component/s: Parallel SQL
    • Labels:

      Description

      The type of aggregation fields returned differs based on the aggregation mode. Here's an example:

      curl --data-urlencode 'stmt=SELECT movie_id, COUNT(*) as agg_count, avg(rating) as avg_rating, sum(rating) as sum_rating, min(rating) as min_rating, max(rating) as max_rating FROM movielens_ratings GROUP BY movie_id ORDER BY movie_id asc' "http://localhost:8984/solr/movielens_ratings/sql?aggregationMode=facet"
      {"result-set":{"docs":[
      {"min_rating":1.0,"avg_rating":3.8783185840707963,"sum_rating":1753.0,"movie_id":"1","agg_count":452,"max_rating":5.0},
      {"min_rating":1.0,"avg_rating":3.831460674157303,"sum_rating":341.0,"movie_id":"10","agg_count":89,"max_rating":5.0},
      {"min_rating":1.0,"avg_rating":4.155511811023622,"sum_rating":2111.0,"movie_id":"100","agg_count":508,"max_rating":5.0},
      {"min_rating":2.0,"avg_rating":3.0,"sum_rating":30.0,"movie_id":"1000","agg_count":10,"max_rating":4.0},
      {"min_rating":1.0,"avg_rating":2.0,"sum_rating":34.0,"movie_id":"1001","agg_count":17,"max_rating":5.0},
      {"min_rating":1.0,"avg_rating":1.875,"sum_rating":15.0,"movie_id":"1002","agg_count":8,"max_rating":4.0},
      {"min_rating":1.0,"avg_rating":2.25,"sum_rating":18.0,"movie_id":"1003","agg_count":8,"max_rating":4.0},
      ...
      
      curl --data-urlencode 'stmt=SELECT movie_id, COUNT(*) as agg_count, avg(rating) as avg_rating, sum(rating) as sum_rating, min(rating) as min_rating, max(rating) as max_rating FROM movielens_ratings GROUP BY movie_id ORDER BY movie_id asc' "http://localhost:8984/solr/movielens_ratings/sql?aggregationMode=map_reduce"
      {"result-set":{"docs":[
      {"min_rating":1,"avg_rating":3.8783185840707963,"sum_rating":1753,"movie_id":"1","agg_count":452,"max_rating":5},
      {"min_rating":1,"avg_rating":3.831460674157303,"sum_rating":341,"movie_id":"10","agg_count":89,"max_rating":5},
      {"min_rating":1,"avg_rating":4.155511811023622,"sum_rating":2111,"movie_id":"100","agg_count":508,"max_rating":5},
      {"min_rating":2,"avg_rating":3.0,"sum_rating":30,"movie_id":"1000","agg_count":10,"max_rating":4},
      {"min_rating":1,"avg_rating":2.0,"sum_rating":34,"movie_id":"1001","agg_count":17,"max_rating":5},
      {"min_rating":1,"avg_rating":1.875,"sum_rating":15,"movie_id":"1002","agg_count":8,"max_rating":4},
      {"min_rating":1,"avg_rating":2.25,"sum_rating":18,"movie_id":"1003","agg_count":8,"max_rating":4},
      {"min_rating":1,"avg_rating":3.111111111111111,"sum_rating":28,"movie_id":"1004","agg_count":9,"max_rating":4},
      {"min_rating":1,"avg_rating":3.6818181818181817,"sum_rating":81,"movie_id":"1005","agg_count":22,"max_rating":5},
      

      The rating field is an integer in Solr (TrieIntField) so one would expect the sum, min, max functions to return Long type but when using aggregationMode=facet, we get back doubles. Data types should be consistent so client applications don't have to account for this weirdness.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                thelabdude Timothy Potter
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: