FAQ
Hi,
if have a query that is working fine with Hive, and I'm trying to get it
working with impala (in the demo VM).

In the query I have a If-Statement in the Select clause and due to that
also in the Group By.
The query looks like:

SELECT table1.column1,
IF(table2.column1 = 'x', table2.column2, table1.column2) AS
somename
FROM
...........
WHERE
...........
GROUP BY IF(table2.column1 = 'x', table2.column2, table1.column2), s.time
HAVING .......,
ORDER BY ....... ASC;

This results in an Error that says: "No matching function with those
arguments: ifBOOLEAN, STRING,INT)"
(It prints that kind of typical AnalysisException stacktrace, but i guess
this is useless here)

The Query works fine (but is senseless for me) in Impala if i remove the if
parts.
So, I guess this is simply not supported in Impala? Is there another Way to
achieve something similar?

Search Discussions

  • Greg Rahn at Apr 3, 2013 at 2:52 pm
    This should be an equivalent syntax that works:

    select
    table1.column1,
    case
    when table2.column1 = 'x'
    then table2.column2
    else table1.column2
    end AS somename

    On Wed, Apr 3, 2013 at 6:02 AM, wrote:

    Hi,
    if have a query that is working fine with Hive, and I'm trying to get it
    working with impala (in the demo VM).

    In the query I have a If-Statement in the Select clause and due to that
    also in the Group By.
    The query looks like:

    SELECT table1.column1,
    IF(table2.column1 = 'x', table2.column2, table1.column2) AS
    somename
    FROM
    ...........
    WHERE
    ...........
    GROUP BY IF(table2.column1 = 'x', table2.column2, table1.column2), s.time
    HAVING .......,
    ORDER BY ....... ASC;

    This results in an Error that says: "No matching function with those
    arguments: ifBOOLEAN, STRING,INT)"
    (It prints that kind of typical AnalysisException stacktrace, but i guess
    this is useless here)

    The Query works fine (but is senseless for me) in Impala if i remove the
    if parts.
    So, I guess this is simply not supported in Impala? Is there another Way
    to achieve something similar?

  • Marcel Kornacker at Apr 3, 2013 at 3:07 pm
    The problem is that your column2's from table1 and table2 have
    different types (string vs. int). You explicitly need to cast one of
    them to the type of the other in the IF statement.
    On Wed, Apr 3, 2013 at 6:02 AM, wrote:
    Hi,
    if have a query that is working fine with Hive, and I'm trying to get it
    working with impala (in the demo VM).

    In the query I have a If-Statement in the Select clause and due to that also
    in the Group By.
    The query looks like:

    SELECT table1.column1,
    IF(table2.column1 = 'x', table2.column2, table1.column2) AS
    somename
    FROM
    ...........
    WHERE
    ...........
    GROUP BY IF(table2.column1 = 'x', table2.column2, table1.column2), s.time
    HAVING .......,
    ORDER BY ....... ASC;

    This results in an Error that says: "No matching function with those
    arguments: ifBOOLEAN, STRING,INT)"
    (It prints that kind of typical AnalysisException stacktrace, but i guess
    this is useless here)

    The Query works fine (but is senseless for me) in Impala if i remove the if
    parts.
    So, I guess this is simply not supported in Impala? Is there another Way to
    achieve something similar?
  • Ealex531 at Apr 4, 2013 at 7:54 am
    Thank you!
    That was the whole point... I guess I could have figured out myself if I
    just red the Doc more carfully, but I just didn't think about the obvious
    thing because I just didnt think of casting since Hive does it implicit for
    you...

    Am Mittwoch, 3. April 2013 17:07:49 UTC+2 schrieb Marcel Kornacker:
    The problem is that your column2's from table1 and table2 have
    different types (string vs. int). You explicitly need to cast one of
    them to the type of the other in the IF statement.
    On Wed, Apr 3, 2013 at 6:02 AM, <eale...@gmail.com <javascript:>> wrote:
    Hi,
    if have a query that is working fine with Hive, and I'm trying to get it
    working with impala (in the demo VM).

    In the query I have a If-Statement in the Select clause and due to that also
    in the Group By.
    The query looks like:

    SELECT table1.column1,
    IF(table2.column1 = 'x', table2.column2, table1.column2) AS
    somename
    FROM
    ...........
    WHERE
    ...........
    GROUP BY IF(table2.column1 = 'x', table2.column2, table1.column2), s.time
    HAVING .......,
    ORDER BY ....... ASC;

    This results in an Error that says: "No matching function with those
    arguments: ifBOOLEAN, STRING,INT)"
    (It prints that kind of typical AnalysisException stacktrace, but i guess
    this is useless here)

    The Query works fine (but is senseless for me) in Impala if i remove the if
    parts.
    So, I guess this is simply not supported in Impala? Is there another Way to
    achieve something similar?

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupimpala-user @
categorieshadoop
postedApr 3, '13 at 1:03p
activeApr 4, '13 at 7:54a
posts4
users3
websitecloudera.com
irc#hadoop

People

Translate

site design / logo © 2022 Grokbase