TheWinds opened a new issue #7766:
URL: https://github.com/apache/pinot/issues/7766


   When using the H3 index, in some cases, the correct filtering of distances 
is not possible.
   
   ## Test case
   ### Data
   
   #### geodata.csv
   ```csv
   name,lng,lat
   a,-103.34056886616187,20.63611463218247
   b,-103.31104310932645,20.606231326034603
   c,-103.33524736347661,20.595626162929634
   ```
   #### schema
   ```json
   {
       "metricFieldSpecs": [],
       "dimensionFieldSpecs": [
           {
               "dataType": "STRING",
               "name": "name"
           },
           {
               "dataType": "FLOAT",
               "name": "lng"
           },
           {
               "dataType": "FLOAT",
               "name": "lat"
           },
           {
               "dataType": "BYTES",
               "name": "location_st_point",
               "transformFunction": "toSphericalGeography(stPoint(lng,lat))"
           }
       ],
       "schemaName": "geodata"
   }
   ```
   
   #### table
   
   ```json
   {
       "tableName": "geodata",
       "tableType": "OFFLINE",
       "segmentsConfig": {
         "retentionTimeUnit": "DAYS",
         "retentionTimeValue": "1",
         "segmentPushType": "APPEND",
         "segmentAssignmentStrategy": "BalanceNumSegmentAssignmentStrategy",
         "schemaName": "geodata",
         "replication": "1"
       },
       "tenants": {
       },
       "fieldConfigList": [
         {
           "name": "location_st_point",
           "encodingType": "RAW",
           "indexType": "H3",
           "properties": {
             "resolutions": "7"
           }
         }
       ],
       "tableIndexConfig": {
         "loadMode": "MMAP",
         "noDictionaryColumns": [
           "location_st_point"
         ]
       },
       "metadata": {
         "customConfigs": {
         }
       }
     }
   ```
   
   ### Query
   ```sql
   select name,
       lat,
       lng,
       ST_DISTANCE(
           location_st_point,
           ST_Point(-103.34417375507813, 20.64061268636347, 1)
       ) as distance
   from geodata
   where ST_DISTANCE(
           location_st_point,
           ST_Point(-103.34417375507813, 20.64061268636347, 1)
       ) < 5000;
   ```
   ### Query Response
   ```csv
   name,lat,lng,distance
   a,20.636114,-103.34057,625.2019871997669
   b,20.606232,-103.31104,5148.1557916677875
   c,20.595627,-103.33525,5087.813601469894
   ```
   
   ## Analysis
   **This appears to be a problem with KRing calculations***
   
   ### Code
   
https://github.com/apache/pinot/blob/e3d238ac1d8633331d9507713266e41e6b40f870/pinot-core/src/main/java/org/apache/pinot/core/operator/filter/H3IndexFilterOperator.java#L186-L198
   
   ### Visualize
   
![poc](https://user-images.githubusercontent.com/13296462/141759466-bc0639cc-0c79-4ea3-8c2e-f28f3d5aa552.png)
   
   
   


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