andrewbridge opened a new issue #10609:
URL: https://github.com/apache/druid/issues/10609


   **Druid version: 0.20.0**
   
   I'm writing a custom aggregation, using 
[implydata/druid-example-extension](https://github.com/implydata/druid-example-extension)
 as a base.
   
   My aggregator factory class is `DoubleMinOfAggregatorFactory`, I'm 
registering it as follows:
   
   ```java
   public List<? extends Module> getJacksonModules()
     {
       return ImmutableList.of(
           new SimpleModule(getClass().getSimpleName()).registerSubtypes(
               new NamedType(DoubleMinOfAggregatorFactory.class, 
DoubleMinOfAggregatorFactory.TYPE_NAME)
           )
       );
     }
   ```
   
   where `TYPE_NAME` is defined in the class as:
   
   ```java
   public static final String TYPE_NAME = "doubleMinOf";
   ```
   
   I've now begun testing the aggregator, constructing the test as:
   
   ```java
   public DoubleMinOfAggregationTest() throws Exception
       {
           String aggSpecJson = "{\"type\": \"doubleMinOf\", \"name\": 
\"finalField\", \"fieldName\": \"base\", \"refFieldName\": \"reference\"}";
           doubleMinAggFactory = 
TestHelper.makeJsonMapper().readValue(aggSpecJson, 
DoubleMinOfAggregatorFactory.class);
       }
   ```
   Running a test throws the following error (condensed for readability):
   
   ```text
   com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve 
type id 'doubleMinOf' as a subtype of 
com.derivitec.druid.minof.aggregator.DoubleMinOfAggregatorFactory: known type 
ids = [DoubleMinOfAggregatorFactory, cardinality, count, ...]
    at [Source: (String)"{"type": "doubleMinOf", "name": "finalField", 
"fieldName": "base", "refFieldName": "reference"}"; line: 1, column: 10]
   ```
   The known type ids list does not include `doubleMinOf` but **does** include 
`DoubleMinOfAggregatorFactory`. Using `DoubleMinOfAggregatorFactory` allows the 
test to run successfully, but I a) don't want to use the class name as a type, 
and b) am concerned that this is a symptom of a bad implementation on my part.
   
   What's the recommended way of associating a type name with an aggregator?


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

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