Ramin Gharib created FLINK-41787:
------------------------------------

             Summary: ATAN2 fails at planning when only one argument is a 
DECIMAL
                 Key: FLINK-41787
                 URL: https://issues.apache.org/jira/browse/FLINK-41787
             Project: Flink
          Issue Type: Bug
          Components: Table SQL / Planner
    Affects Versions: 2.3.0
            Reporter: Ramin Gharib


ATAN2 fails with {{Unsupported call}} when one argument is a DECIMAL and the 
other is an integer or a DOUBLE. Two DECIMAL arguments work, and so do two 
arguments of other numeric types. A literal such as {{1.0}} is a DECIMAL, so 
{{ATAN2(y, 1.0)}} fails for an INT column {{y}}.

{code:sql}
SELECT y, ATAN2(y, 1.0) AS a FROM (VALUES (1), (2)) AS t(y);
SELECT d, ATAN2(d, 1.0E0) AS a FROM (VALUES (1.0), (2.0)) AS t(d);
{code}

||Call||Expected for 1||Actual||
|{{ATAN2(y, 1.0)}}, {{y}} INT|0.7853981633974483|{{CodeGenException: 
Unsupported call: ATAN2(INT NOT NULL, DECIMAL(2, 1) NOT NULL)}}|
|{{ATAN2(d, 1.0E0)}}, {{d}} DECIMAL|0.7853981633974483|{{CodeGenException: 
Unsupported call: ATAN2(DECIMAL(2, 1) NOT NULL, DOUBLE NOT NULL)}}|
|{{ATAN2(y, 1.0E0)}}|0.7853981633974483|0.7853981633974483|
|{{ATAN2(d, 1.0)}}|0.7853981633974483|0.7853981633974483|

The same in batch and streaming mode, and in the Table API.

h3. Cause
{{FunctionGenerator}} registers ATAN2 only for (DOUBLE, DOUBLE) and (DECIMAL, 
DECIMAL) (lines 111-113), and the lookup matches a DECIMAL argument only with a 
DECIMAL parameter. POWER and LOG register the mixed pairs, such as 
{{POWER_NUM_DEC}} and {{POWER_DEC_NUM}}.

h3. Proposal
Register (DOUBLE, DECIMAL) and (DECIMAL, DOUBLE) for ATAN2, as for POWER.




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to