[ https://issues.apache.org/jira/browse/IMPALA-14168 ]


    weihua zhang deleted comment on IMPALA-14168:
    ---------------------------------------

was (Author: JIRAUSER307426):
[~scarlin]

java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/FunctionResolver.java


{code:java}
  private static Function getSpecialProcessingFunction(String lowercaseName,
      List<Type> impalaArgTypes, boolean exactMatch) {
    if (lowercaseName.equals("grouping_id")) {
      return AggregateFunction.createRewrittenBuiltin(BuiltinsDb.getInstance(),
          lowercaseName, impalaArgTypes, Type.BIGINT, true, false, true);
    }

    // Hack.  The count function can have more than one parameter when it is
    // of the form "count(distinct c1, c2)"  However, the function resolver only
    // contains count functions with one parameter. It is only later on in
    // the compilation that the AggregateInfo class changes the multiple
    // parameters into one parameter. But we still have to deal with resolving
    // count here.  So we just grab the first parameter so that it resolves
    // properly.
    if (lowercaseName.equals("count")) {
      if (impalaArgTypes.size() > 1) {
        impalaArgTypes = Lists.newArrayList(impalaArgTypes.get(0));
      }
      return getImpalaFunction(lowercaseName, impalaArgTypes, false);    // 
<------  here change to false
    }

    throw new RuntimeException("Special function not found: " + lowercaseName);
  }
{code}

> Calcite Planner: Could not find the Impala function for COUNT
> -------------------------------------------------------------
>
>                 Key: IMPALA-14168
>                 URL: https://issues.apache.org/jira/browse/IMPALA-14168
>             Project: IMPALA
>          Issue Type: Sub-task
>            Reporter: weihua zhang
>            Priority: Major
>
> {code:sql}
> CREATE TABLE test_varchar_col(varchar_col VARCHAR(20));
> INSERT INTO test_varchar_col values(CAST('grape' AS VARCHAR(20)));
> set use_calcite_planner=1;         
> SELECT COUNT(DISTINCT varchar_col) FROM test_varchar_col;
> 2025-06-18 07:40:21 [Exception]  ERROR: Query 
> 7d4d22d4e91e20ea:cbf92e3400000000 failed:
> IllegalStateException: Could not find the Impala function for COUNT
> set use_calcite_planner=0;                            
> SELECT COUNT(DISTINCT varchar_col) FROM test_varchar_col;
> +-----------------------------+
> | count(distinct varchar_col) |
> +-----------------------------+
> | 1                           |
> +-----------------------------+
> {code}



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to