You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2020/11/27 11:15:55 UTC
[GitHub] [druid] andrewbridge opened a new issue #10609: Custom aggregation type name not registering correctly
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] andrewbridge commented on issue #10609: Custom aggregation type name not registering correctly
Posted by GitBox <gi...@apache.org>.
andrewbridge commented on issue #10609:
URL: https://github.com/apache/druid/issues/10609#issuecomment-744022039
I placed:
```java
@JsonSubTypes(value = {
@JsonSubTypes.Type(name = "doubleMinOf", value = DoubleMinOfAggregatorFactor.class)
})
```
into my extension module file which provides the Jackson module and the aggregator was available as expected within Druid queries.
Many thanks for your help.
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] FrankChen021 commented on issue #10609: Custom aggregation type name not registering correctly
Posted by GitBox <gi...@apache.org>.
FrankChen021 commented on issue #10609:
URL: https://github.com/apache/druid/issues/10609#issuecomment-737028786
it's about jackson deserialization. Take a look at [here](https://github.com/apache/druid/blob/2e02eebd9d09d27dd2e8f73b40dc95eec6d56531/processing/src/main/java/org/apache/druid/jackson/AggregatorsModule.java#L96) and see how to declare a subtype for jackson.
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] andrewbridge closed issue #10609: Custom aggregation type name not registering correctly
Posted by GitBox <gi...@apache.org>.
andrewbridge closed issue #10609:
URL: https://github.com/apache/druid/issues/10609
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] andrewbridge commented on issue #10609: Custom aggregation type name not registering correctly
Posted by GitBox <gi...@apache.org>.
andrewbridge commented on issue #10609:
URL: https://github.com/apache/druid/issues/10609#issuecomment-737925029
Okay, great. Does this mean I have to create a child class off of SimpleModule for every extension or can I use this annotations elsewhere?
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] andrewbridge edited a comment on issue #10609: Custom aggregation type name not registering correctly
Posted by GitBox <gi...@apache.org>.
andrewbridge edited a comment on issue #10609:
URL: https://github.com/apache/druid/issues/10609#issuecomment-744022039
I placed:
```java
@JsonSubTypes(value = {
@JsonSubTypes.Type(name = "doubleMinOf", value = DoubleMinOfAggregatorFactory.class)
})
```
into my extension module file which provides the Jackson module and the aggregator was available as expected within Druid queries.
Many thanks for your help.
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org