Class JsonObjectAggFunction
- java.lang.Object
-
- org.apache.flink.table.functions.UserDefinedFunction
-
- org.apache.flink.table.functions.ImperativeAggregateFunction<T,ACC>
-
- org.apache.flink.table.functions.AggregateFunction<T,ACC>
-
- org.apache.flink.table.runtime.functions.aggregate.BuiltInAggregateFunction<String,JsonObjectAggFunction.Accumulator>
-
- org.apache.flink.table.runtime.functions.aggregate.JsonObjectAggFunction
-
- All Implemented Interfaces:
Serializable
,FunctionDefinition
@Internal public class JsonObjectAggFunction extends BuiltInAggregateFunction<String,JsonObjectAggFunction.Accumulator>
Implementation forBuiltInFunctionDefinitions.JSON_OBJECTAGG_NULL_ON_NULL
/BuiltInFunctionDefinitions.JSON_OBJECTAGG_ABSENT_ON_NULL
.Note that this function only ever receives strings to accumulate because
WrapJsonAggFunctionArgumentsRule
wraps arguments intoBuiltInFunctionDefinitions.JSON_STRING
.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JsonObjectAggFunction.Accumulator
Accumulator forJsonObjectAggFunction
.
-
Constructor Summary
Constructors Constructor Description JsonObjectAggFunction(LogicalType[] argumentTypes, boolean skipNulls)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accumulate(JsonObjectAggFunction.Accumulator acc, StringData keyData, StringData valueData)
JsonObjectAggFunction.Accumulator
createAccumulator()
Creates and initializes the accumulator for thisImperativeAggregateFunction
.DataType
getAccumulatorDataType()
List<DataType>
getArgumentDataTypes()
DataType
getOutputDataType()
String
getValue(JsonObjectAggFunction.Accumulator acc)
Called every time when an aggregation result should be materialized.void
merge(JsonObjectAggFunction.Accumulator acc, Iterable<JsonObjectAggFunction.Accumulator> others)
void
resetAccumulator(JsonObjectAggFunction.Accumulator acc)
void
retract(JsonObjectAggFunction.Accumulator acc, StringData keyData, StringData valueData)
-
Methods inherited from class org.apache.flink.table.runtime.functions.aggregate.BuiltInAggregateFunction
getRequirements, getTypeInference, isDeterministic
-
Methods inherited from class org.apache.flink.table.functions.AggregateFunction
getKind
-
Methods inherited from class org.apache.flink.table.functions.ImperativeAggregateFunction
getAccumulatorType, getResultType
-
Methods inherited from class org.apache.flink.table.functions.UserDefinedFunction
close, functionIdentifier, open, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.flink.table.functions.FunctionDefinition
supportsConstantFolding
-
-
-
-
Constructor Detail
-
JsonObjectAggFunction
public JsonObjectAggFunction(LogicalType[] argumentTypes, boolean skipNulls)
-
-
Method Detail
-
getArgumentDataTypes
public List<DataType> getArgumentDataTypes()
- Overrides:
getArgumentDataTypes
in classBuiltInAggregateFunction<String,JsonObjectAggFunction.Accumulator>
-
getOutputDataType
public DataType getOutputDataType()
- Overrides:
getOutputDataType
in classBuiltInAggregateFunction<String,JsonObjectAggFunction.Accumulator>
-
getAccumulatorDataType
public DataType getAccumulatorDataType()
- Overrides:
getAccumulatorDataType
in classBuiltInAggregateFunction<String,JsonObjectAggFunction.Accumulator>
-
createAccumulator
public JsonObjectAggFunction.Accumulator createAccumulator()
Description copied from class:ImperativeAggregateFunction
Creates and initializes the accumulator for thisImperativeAggregateFunction
.The accumulator is an intermediate data structure that stores the aggregated values until a final aggregation result is computed.
- Specified by:
createAccumulator
in classImperativeAggregateFunction<String,JsonObjectAggFunction.Accumulator>
- Returns:
- the accumulator with the initial value
-
resetAccumulator
public void resetAccumulator(JsonObjectAggFunction.Accumulator acc)
-
accumulate
public void accumulate(JsonObjectAggFunction.Accumulator acc, StringData keyData, @Nullable StringData valueData) throws Exception
- Throws:
Exception
-
retract
public void retract(JsonObjectAggFunction.Accumulator acc, StringData keyData, @Nullable StringData valueData) throws Exception
- Throws:
Exception
-
merge
public void merge(JsonObjectAggFunction.Accumulator acc, Iterable<JsonObjectAggFunction.Accumulator> others) throws Exception
- Throws:
Exception
-
getValue
public String getValue(JsonObjectAggFunction.Accumulator acc)
Description copied from class:AggregateFunction
Called every time when an aggregation result should be materialized. The returned value could be either an early and incomplete result (periodically emitted as data arrives) or the final result of the aggregation.- Specified by:
getValue
in classAggregateFunction<String,JsonObjectAggFunction.Accumulator>
- Parameters:
acc
- the accumulator which contains the current intermediate results- Returns:
- the aggregation result
-
-