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

Jacky Lau edited comment on FLINK-32257 at 7/5/23 2:46 AM:
-----------------------------------------------------------

hi [~dwysakowicz]  [~hanyuzheng] [~Sergey Nuyanzin] , the array_max return type 
i submitted has fixed and merged.

and i found another problem. why array_max don't support array/row type. spark 
supports it
{code:java}
// code placeholder
def isOrderable(dataType: DataType): Boolean = dataType match {
  case NullType => true
  case dt: AtomicType => true
  case struct: StructType => struct.fields.forall(f => isOrderable(f.dataType))
  case array: ArrayType => isOrderable(array.elementType)
  case udt: UserDefinedType[_] => isOrderable(udt.sqlType)
  case _ => false
} {code}
and our flink has also supported in code gen for example in the 
ComparableTypeStrategy, the ArrayComparableElementTypeStrategy refers to 
ComparableTypeStrategy, but don't put areTypesOfSameRootComparable
what do you think?
{code:java}
public static final BuiltInFunctionDefinition GREATEST =
        BuiltInFunctionDefinition.newBuilder()
                .name("GREATEST")
                .kind(SCALAR)
                .inputTypeStrategy(
                        comparable(ConstantArgumentCount.from(1), 
StructuredComparison.FULL))
                .outputTypeStrategy(nullableIfArgs(TypeStrategies.COMMON))
                .runtimeProvided()
                .build(); {code}


was (Author: jackylau):
hi [~dwysakowicz] , the array_max return type has fixed and merged.

and i found another problem. why array_max don't support array/row type. spark 
supports it
{code:java}
// code placeholder
def isOrderable(dataType: DataType): Boolean = dataType match {
  case NullType => true
  case dt: AtomicType => true
  case struct: StructType => struct.fields.forall(f => isOrderable(f.dataType))
  case array: ArrayType => isOrderable(array.elementType)
  case udt: UserDefinedType[_] => isOrderable(udt.sqlType)
  case _ => false
} {code}
and our flink has also supported in code gen for example in the 
ComparableTypeStrategy, the ArrayComparableElementTypeStrategy refers to 
ComparableTypeStrategy, but don't put areTypesOfSameRootComparable
what do you think?

> Add ARRAY_MAX support in SQL & Table API
> ----------------------------------------
>
>                 Key: FLINK-32257
>                 URL: https://issues.apache.org/jira/browse/FLINK-32257
>             Project: Flink
>          Issue Type: Improvement
>          Components: Table SQL / Planner
>    Affects Versions: 1.18.0
>            Reporter: Bonnie Varghese
>            Assignee: Hanyu Zheng
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.18.0
>
>
> This is an implementation of ARRAY_MAX
> The array_max() function concatenates get the maximum element from input 
> array.
> The result matches the type of the elements. NULL elements are skipped. If 
> array is empty, or contains only NULL elements, NULL is returned.
>  
> Syntax
> array_max(array)
> Arguments
> array: Any ARRAY with elements for which order is supported.
>  
> Returns
> The result matches the type of the elements. NULL elements are skipped. If 
> array is empty, or contains only NULL elements, NULL is returned.
>  
> Examples
> SQL
>  
> > SELECT array_max(array(1, 20, NULL, 3)); 20
>  
> {code:java}
> // Fink SQL-> select array_max(array[1, 20, null, 3])
> 20{code}
>  
> See also
> spark 
> [https://spark.apache.org/docs/latest/api/sql/index.html#array_max|https://spark.apache.org/docs/latest/api/sql/index.html#array_min]
> presto [https://prestodb.io/docs/current/functions/array.html]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to