From eb0bae49eca5013c7121994e20f9cd8146df8424 Mon Sep 17 00:00:00 2001 From: imply-cheddar <86940447+imply-cheddar@users.noreply.github.com> Date: Tue, 11 Jan 2022 19:18:14 +0900 Subject: [PATCH] Update PostAggregator to be backwards compat (#12138) This change mimics what was done in PR #11917 to fix the incompatibilities produced by #11713. #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 --- .../query/aggregation/PostAggregator.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/PostAggregator.java b/processing/src/main/java/org/apache/druid/query/aggregation/PostAggregator.java index 06e64af1287..399947afb34 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/PostAggregator.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/PostAggregator.java @@ -23,6 +23,8 @@ import org.apache.druid.guice.annotations.ExtensionPoint; 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; @@ -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