[ 
https://issues.apache.org/jira/browse/FLINK-20373?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17242359#comment-17242359
 ] 

HideOnBush commented on FLINK-20373:
------------------------------------

 
{code:java}
class ExplodeArray() extends TableFunction[AnyRef] {

  //FLINK SQL ARRAY<ROW> to ROW
  def eval(array: Array[AnyRef])(): Unit = {
    if (array == null) {
      return
    }
    array.foreach(collect)
  }
  
  override def getTypeInference(typeFactory: DataTypeFactory): TypeInference = {
    new TypeInference.Builder().inputTypeStrategy(new 
ArrayInputTypeStrategy()).outputTypeStrategy(new TypeStrategy {
      override def inferType(callContext: CallContext): Optional[DataType] = {
        Optional.of(callContext.getArgumentDataTypes.get(0).getChildren.get(0))
      }
    })
  }.build()
}
 
{code}
 

I Code the UDF to Explode Flink SQL JSON Array

> Flink table jsonArray access all
> --------------------------------
>
>                 Key: FLINK-20373
>                 URL: https://issues.apache.org/jira/browse/FLINK-20373
>             Project: Flink
>          Issue Type: New Feature
>          Components: Table SQL / Client
>    Affects Versions: 1.11.2
>            Reporter: HideOnBush
>            Priority: Major
>
> The official jsonArray is provided, and the array is also provided to access 
> Row elements based on the subscript. Should we also consider the length of 
> each jsonArray, and if the subscript is passed, the code will become longer



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to