walterddr commented on a change in pull request #7237: [FLINK-7209] [table] 
Support DataView in Tuple and Case Class as the ACC type of AggregateFunction
URL: https://github.com/apache/flink/pull/7237#discussion_r242392587
 
 

 ##########
 File path: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/functions/utils/UserDefinedFunctionUtils.scala
 ##########
 @@ -489,6 +491,88 @@ object UserDefinedFunctionUtils {
       )
     }
 
+    def decorateDataViewTypeInfo(
+        fieldTypeInfo: TypeInformation[_],
+        fieldInstance: AnyRef,
+        field: Field): (TypeInformation[_], Option[DataViewSpec[_]]) = 
fieldTypeInfo match {
+      case ct: CompositeType[_] if includesDataView(ct) =>
+        throw new TableException(
+          "MapView and ListView only supported at first level of accumulators 
of Pojo, Tuple " +
+            "and Case Class type.")
+      case map: MapViewTypeInfo[_, _] =>
+        val mapView = fieldInstance.asInstanceOf[MapView[_, _]]
+        val newTypeInfo = if (mapView != null && mapView.keyTypeInfo != null &&
+          mapView.valueTypeInfo != null) {
+          new MapViewTypeInfo(mapView.keyTypeInfo, mapView.valueTypeInfo)
+        } else {
+          map
+        }
+
+        if (isStateBackedDataViews) {
+          newTypeInfo.nullSerializer = true
+
+          // create map view specs with unique id (used as state name)
+          val fieldName = field.getName
+          var spec = MapViewSpec(
+            "agg" + index + "$" + fieldName,
+            field,
+            newTypeInfo)
+
+          (newTypeInfo, Some(spec))
+        } else {
+          (newTypeInfo, None)
+        }
+
+      case list: ListViewTypeInfo[_] =>
 
 Review comment:
   Maybe add a ListView test case?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to