nicolasblaye commented on issue #6018: RegisteredLookup java api
URL: 
https://github.com/apache/incubator-druid/issues/6018#issuecomment-406201106
 
 
   Hi drcrallen,
   
   Thank you for your quick response. Indeed, this class is in the druid server 
jar, but I need it in the druid-api jar (or at least in the extension).
   
   My use case:
   
   I have globally cached lookups and a java api. The java api gives dashboards 
using druid queries. The query are done via the java api. In this api, I have 
no way to call a registered lookup because there is no extractor for it.
   
   Some code for more precision:
   
   This is the request I want to do (and it works using the json api)
   ``` json
   {
     "dimensions": [
       {
         "type" : "extraction",
         "dimension" : "a_dimension",
         "outputName" : "toto",
         "extractionFn": {
             "type":"registeredLookup",
             "lookup": "a_lookup",
             "retainMissingValue":true,
             "injective":true
         }
       }
     ], 
     "aggregations": [
       {
         "type": "longSum", 
         "fieldName": "count", 
         "name": "sum__count"
       }
     ], 
     "intervals": "2018-07-13T00:00:00+00:00/2018-07-18T12:56:20+00:00", 
     "limitSpec": {
       "limit": 5000, 
       "type": "default", 
       "columns": [
         {
           "direction": "descending", 
           "dimension": "sum__count"
         }
       ]
     }, 
     "granularity": "day", 
     "postAggregations": [], 
     "queryType": "groupBy", 
     "dataSource": "datasource"
   }
   ```
   
   This is how we try to get the lookup in our java-api. Notice the lookup 
extractor inside the `LookupExtractionFn`
   
   ``` java
       /**
        * Return the dimension spec of the given column name: it can be a 
classic column name but also a lookup.
        */
       private static DimensionSpec getDimensionSpec(String name) {
           String lookupFrom = lookups.get(name);
           if (!(lookupFrom == null || lookupFrom.length() == 0)) {
               return new ExtractionDimensionSpec(lookupFrom, name, new 
LookupExtractionFn(new LookupExtractor(name), true, null, null, null));
           } else {
               return new DefaultDimensionSpec(name, name);
           }
       }
   ```
   And this is all the available lookup extractor
   ```
   @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
   @JsonSubTypes(value = {
       @JsonSubTypes.Type(name = "map", value = MapLookupExtractor.class)
   })
   public abstract class LookupExtractor
   ```
   
   I looked into 
https://mvnrepository.com/artifact/io.druid.extensions/druid-lookups-cached-global
 but couldn't find the `registeredLookup`, only 
`@JsonTypeName("cachedNamespace")`
   
   Hope this was clearer.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to