You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "Volnei (Jira)" <ji...@apache.org> on 2020/06/08 16:38:00 UTC

[jira] [Commented] (IMPALA-9836) IllegalStateException when UDF is evaluated with NULL inputs and returns error

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

Volnei commented on IMPALA-9836:
--------------------------------

Hi Tim,

well ... the table is very simple, it only has a string type field (slog).

if I use the UDF inside an 'if()' the content of the field is passed to the function.
 e.g:
{code:java}
select 
if( squid_totalsize_req("squid", slog)) > 500, "ok", "no")
from squidlog
{code}
 
 What do you think about this.
 Thanks.

The function is this:
{code:java}
IMPALA_UDF_EXPORT
BigIntVal udf_totalsizereq(FunctionContext* ctx, const StringVal& logformat,
                    const StringVal& log)
{
  if(logformat.is_null || logformat.len == 0) {
    std::stringstream ss;
    ss << "Argument 1 (LOGFORMAT): Cannot be empty. ";
    ctx->SetError(ss.str().c_str());
    return BigIntVal::null();
  }

  if(log.is_null || log.len == 0) {
    std::stringstream ss;
    ss << "Argument 2 (LOG): Cannot be empty. ";
    ctx->SetError(ss.str().c_str());
    return BigIntVal::null();
  }

  std::string slogformat((const char *)logformat.ptr, logformat.len);
  std::string slog((const char *)log.ptr, log.len);

  std::string f="squidcommoncombined";
  std::size_t found = f.find(slogformat);
  if( found == std::string::npos) {
    std::stringstream ss;
    ss << "Argument 1 (LOGFORMAT): Invalid!. Valid are: squid|common|combined";
    ctx->SetError(ss.str().c_str());
    return BigIntVal::null();
  }

  LogSquid ls;
  ls.setFormat(slogformat);
  ls.setLogReg(slog);
  int64_t tsq = ls.getTotalSizeReq();

  return tsq; //BigIntVal(tsq);
}
{code}

> IllegalStateException when UDF is evaluated with NULL inputs and returns error
> ------------------------------------------------------------------------------
>
>                 Key: IMPALA-9836
>                 URL: https://issues.apache.org/jira/browse/IMPALA-9836
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Frontend
>    Affects Versions: Impala 2.12.0
>         Environment: Cloudera QuickStart 5.16.2
> gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
> impala-2.12.0+cdh5.16.2+0-1.cdh5.16.2.p0.22.el6.x86_64
> impala-shell-2.12.0+cdh5.16.2+0-1.cdh5.16.2.p0.22.el6.x86_64
> impala-state-store-2.12.0+cdh5.16.2+0-1.cdh5.16.2.p0.22.el6.x86_64
> impala-server-2.12.0+cdh5.16.2+0-1.cdh5.16.2.p0.22.el6.x86_64
> impala-udf-devel-2.12.0+cdh5.16.2+0-1.cdh5.16.2.p0.22.el6.x86_64
> hue-impala-3.9.0+cdh5.16.2+8463-1.cdh5.16.2.p0.26.el6.x86_64
> impala-catalog-2.12.0+cdh5.16.2+0-1.cdh5.16.2.p0.22.el6.x86_64
>            Reporter: Volnei
>            Priority: Major
>
> Hi,
> Is there any known reason that when we code a C++ UDF, the error below happens?
> {code:java}
> select sum(squid_totalsize_req("squid", slog))
> from squidlog
> where squid_totalsize_req("squid", slog) < 500;
> /IllegalStateException: Failed to evaluate generated predicate: squidlogs.squid_totalsize_req('squid', NULL) < 500.Argument 2 (LOG): Cannot be empty.
> {code}
> Whenever I use the UDF in the 'where' clause, the field is passed with a null value.
> Thanks a lot for the help.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org