Skip to content

Commit

Permalink
Update PostAggregator to be backwards compat (apache#12138)
Browse files Browse the repository at this point in the history
This change mimics what was done in PR apache#11917 to
fix the incompatibilities produced by apache#11713. apache#11917
fixed it with AggregatorFactory by creating default
methods to allow for extensions built against old
jars to still work.  This does the same for PostAggregator
  • Loading branch information
imply-cheddar authored Jan 11, 2022
1 parent 7cf9192 commit eb0bae4
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.apache.druid.java.util.common.Cacheable;
import org.apache.druid.segment.ColumnInspector;
import org.apache.druid.segment.column.ColumnType;
import org.apache.druid.segment.column.ColumnTypeFactory;
import org.apache.druid.segment.column.ValueType;

import javax.annotation.Nullable;
import java.util.Comparator;
Expand All @@ -48,10 +50,27 @@ public interface PostAggregator extends Cacheable
/**
* Return the output type of a row processed with this post aggregator. Refer to the {@link ColumnType} javadocs
* for details on the implications of choosing a type.
*
* @param signature
*/
@Nullable
ColumnType getType(ColumnInspector signature);
default ColumnType getType(ColumnInspector signature)
{
return ColumnTypeFactory.ofValueType(getType());
}

/**
* This method is deprecated and will be removed soon. Use {@link #getType(ColumnInspector)} instead. Do not call this
* method, it will likely produce incorrect results, it exists for backwards compatibility.
*/
@Deprecated
default ValueType getType()
{
throw new UnsupportedOperationException(
"Do not call or implement this method, it is deprecated, use 'getType(ColumnInspector)' instead"
);
}


/**
* Allows returning an enriched post aggregator, built from contextual information available from the given map of
Expand Down

0 comments on commit eb0bae4

Please sign in to comment.