weizhengte opened a new pull request, #15317:
URL: https://github.com/apache/doris/pull/15317

   # Proposed changes
   
   This pr mainly to optimize the histogram aggregation function. Including the 
following:
   1. Support input parameters `sample_rate` and `max_bucket_num`
   2. Add UT and regression test
   3. Add documentation
   4. Optimize function implementation logic
    
   Parameter description:
   - sample_rate:Optional. The proportion of sample data used to generate the 
histogram. The default is 0.2.
   - max_bucket_num:Optional. Limit the number of histogram buckets. The 
default value is 128.
   
   ---
   
   example:
   
   ```
   MySQL [test]> SELECT histogram(c_float) FROM histogram_test;
   
+-------------------------------------------------------------------------------------------------------------------------------------+
   | histogram(`c_float`)                                                       
                                                         |
   
+-------------------------------------------------------------------------------------------------------------------------------------+
   | 
{"sample_rate":0.2,"max_bucket_num":128,"bucket_num":3,"buckets":[{"lower":"0.1","upper":"0.1","count":1,"pre_sum":0,"ndv":1},...]}
 |
   
+-------------------------------------------------------------------------------------------------------------------------------------+
   
   MySQL [test]> SELECT histogram(c_string, 0.5, 2) FROM histogram_test;
   
+-------------------------------------------------------------------------------------------------------------------------------------+
   | histogram(`c_string`)                                                      
                                                         |
   
+-------------------------------------------------------------------------------------------------------------------------------------+
   | 
{"sample_rate":0.5,"max_bucket_num":2,"bucket_num":2,"buckets":[{"lower":"str1","upper":"str7","count":4,"pre_sum":0,"ndv":3},...]}
 |
   
+-------------------------------------------------------------------------------------------------------------------------------------+
   ```
   
   Query result description:
   
   ```
   {
       "sample_rate": 0.2, 
       "max_bucket_num": 128, 
       "bucket_num": 3, 
       "buckets": [
           {
               "lower": "0.1", 
               "upper": "0.2", 
               "count": 2, 
               "pre_sum": 0, 
               "ndv": 2
           }, 
           {
               "lower": "0.8", 
               "upper": "0.9", 
               "count": 2, 
               "pre_sum": 2, 
               "ndv": 2
           }, 
           {
               "lower": "1.0", 
               "upper": "1.0", 
               "count": 2, 
               "pre_sum": 4, 
               "ndv": 1
           }
       ]
   }
   ```
   
   Field description:
   - sample_rate:Rate of sampling
   - max_bucket_num:Limit the maximum number of buckets
   - bucket_num:The actual number of buckets
   - buckets:All buckets
       - lower:Upper bound of the bucket
       - upper:Lower bound of the bucket
       - count:The number of elements contained in the bucket
       - pre_sum:The total number of elements in the front bucket
       - ndv:The number of different values in the bucket
   
   Issue Number: close #xxx
   
   ## Problem summary
   
   Describe your changes.
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: 
       - [ ] Yes
       - [ ] No
       - [ ] I don't know
   5. Has unit tests been added:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   6. Has document been added or modified:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   7. Does it need to update dependencies:
       - [ ] Yes
       - [ ] No
   8. Are there any changes that cannot be rolled back:
       - [ ] Yes (If Yes, please explain WHY)
       - [ ] No
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at 
[[email protected]](mailto:[email protected]) by explaining why you 
chose the solution you did and what alternatives you considered, etc...
   
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to