[ https://issues.apache.org/jira/browse/FLINK-27145?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jingsong Lee closed FLINK-27145. -------------------------------- Resolution: Fixed master: 27c3f47781f3a9f0b804219c7b8037fe4a00dc75 > The code generated for agg function accepts empty parameters can't be compiled > ------------------------------------------------------------------------------ > > Key: FLINK-27145 > URL: https://issues.apache.org/jira/browse/FLINK-27145 > Project: Flink > Issue Type: Bug > Components: Table SQL / Planner > Reporter: luoyuxia > Assignee: luoyuxia > Priority: Major > Labels: pull-request-available > Fix For: 1.16.0 > > > In batch mode, when I try to call Hive's `count` function(GenericUDAFCount) > using the following sql: > {code:java} > select count(*) from src; > {code} > It'll throw the exception "Unexpected token ")" in primary" while compling > the generated code. > It happens in the following generated code: > {code:java} > function_org$apache$flink$table$planner$utils$xxx.accumulate( > acc$7,); {code} > > The reason is the following code in method > `AggCodeGenHelper#genAccumulateFlatAggregateBuffer` > {code:java} > s""" > |$externalAccTypeTerm $externalAccTerm = $externalAccCode; > |${functionIdentifiers(function)}.accumulate( > | $externalAccTerm, > | ${operandTerms.mkString(", ")}); // but operandTerms can be empty list > |$aggBufferName = ${genToInternalConverter(ctx, > externalAccType)(externalAccTerm)}; > |${aggBufferExpr.nullTerm} = false; > """.stripMargin {code} > In this case, for count(\*), it'll be regarded as an agg function with empty > parameter in Hive. > So, the exception happens. > Although the agg function with empty parameter is rare, it may happens. We > should make the code more rubst. -- This message was sent by Atlassian Jira (v8.20.7#820007)