ywyg commented on issue #14485:
URL: https://github.com/apache/druid/issues/14485#issuecomment-1647715178

   @abhishekagarwal87  ok. When I set `useApproximateCountDistinct=true` and 
the native plan is 
   
   ```
   {
     "queryType": "groupBy",
     "dataSource": {
       "type": "table",
       "name": "inline_data"
     },
     "intervals": {
       "type": "intervals",
       "intervals": [
         "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z"
       ]
     },
     "granularity": {
       "type": "all"
     },
     "dimensions": [
       {
         "type": "default",
         "dimension": "channel",
         "outputName": "d0",
         "outputType": "STRING"
       }
     ],
     "aggregations": [
       {
         "type": "grouping",
         "name": "a0",
         "groupings": [
           "channel"
         ]
       },
       {
         "type": "cardinality",
         "name": "a1",
         "fields": [
           {
             "type": "default",
             "dimension": "page",
             "outputName": "page",
             "outputType": "STRING"
           }
         ],
         "byRow": false,
         "round": true
       }
     ],
     "limitSpec": {
       "type": "default",
       "columns": [],
       "limit": 1001
     },
     "subtotalsSpec": [
       [
         "d0"
       ],
       []
     ],
     "context": {
       "queryId": "edd6fd0b-885f-42fb-8d72-949633d5e066",
       "sqlOuterLimit": 1001,
       "sqlQueryId": "edd6fd0b-885f-42fb-8d72-949633d5e066",
       "sqlTimeZone": "Asia/Shanghai",
       "useApproximateCountDistinct": true,
       "useGroupingSetForExactDistinct": true,
       "useNativeQueryExplain": true
     }
   }
   
   ```
   
   I can get index value , But when I set `useApproximateCountDistinct=false` ,
   
   ```
   
   {
     "queryType": "groupBy",
     "dataSource": {
       "type": "query",
       "query": {
         "queryType": "groupBy",
         "dataSource": {
           "type": "table",
           "name": "inline_data"
         },
         "intervals": {
           "type": "intervals",
           "intervals": [
             "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z"
           ]
         },
         "granularity": {
           "type": "all"
         },
         "dimensions": [
           {
             "type": "default",
             "dimension": "channel",
             "outputName": "d0",
             "outputType": "STRING"
           },
           {
             "type": "default",
             "dimension": "page",
             "outputName": "d1",
             "outputType": "STRING"
           }
         ],
         "aggregations": [
           {
             "type": "grouping",
             "name": "a0",
             "groupings": [
               "channel"
             ]
           },
           {
             "type": "grouping",
             "name": "a1",
             "groupings": [
               "channel",
               "page"
             ]
           }
         ],
         "limitSpec": {
           "type": "NoopLimitSpec"
         },
         "subtotalsSpec": [
           [
             "d0",
             "d1"
           ],
           [
             "d0"
           ]
         ],
         "context": {
           "queryId": "a08217d2-b262-4cad-98ad-5a6f1faaa446",
           "sqlOuterLimit": 1001,
           "sqlQueryId": "a08217d2-b262-4cad-98ad-5a6f1faaa446",
           "sqlTimeZone": "Asia/Shanghai",
           "useApproximateCountDistinct": false,
           "useGroupingSetForExactDistinct": true,
           "useNativeQueryExplain": true
         }
       }
     },
     "intervals": {
       "type": "intervals",
       "intervals": [
         "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z"
       ]
     },
     "granularity": {
       "type": "all"
     },
     "dimensions": [
       {
         "type": "default",
         "dimension": "d0",
         "outputName": "_d0",
         "outputType": "STRING"
       }
     ],
     "aggregations": [
       {
         "type": "filtered",
         "aggregator": {
           "type": "longMin",
           "name": "_a0",
           "fieldName": "a0"
         },
         "filter": {
           "type": "selector",
           "dimension": "a1",
           "value": "1"
         },
         "name": "_a0"
       },
       {
         "type": "filtered",
         "aggregator": {
           "type": "count",
           "name": "_a1"
         },
         "filter": {
           "type": "and",
           "fields": [
             {
               "type": "not",
               "field": {
                 "type": "selector",
                 "dimension": "d1",
                 "value": null
               }
             },
             {
               "type": "selector",
               "dimension": "a1",
               "value": "0"
             }
           ]
         },
         "name": "_a1"
       }
     ],
     "limitSpec": {
       "type": "default",
       "columns": [],
       "limit": 1001
     },
     "subtotalsSpec": [
       [
         "_d0"
       ],
       []
     ],
     "context": {
       "queryId": "a08217d2-b262-4cad-98ad-5a6f1faaa446",
       "sqlOuterLimit": 1001,
       "sqlQueryId": "a08217d2-b262-4cad-98ad-5a6f1faaa446",
       "sqlTimeZone": "Asia/Shanghai",
       "useApproximateCountDistinct": false,
       "useGroupingSetForExactDistinct": true,
       "useNativeQueryExplain": true
     }
   }
   ```
   The value of index all is 0. Looking forward to your reply


-- 
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: commits-unsubscr...@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to