Kirill Tkalenko created CALCITE-7836:
----------------------------------------

             Summary: Array functions return incorrect results for ROW elements
                 Key: CALCITE-7836
                 URL: https://issues.apache.org/jira/browse/CALCITE-7836
             Project: Calcite
          Issue Type: Bug
            Reporter: Kirill Tkalenko
            Assignee: Kirill Tkalenko


Array functions compare {{ROW}} elements by reference rather than by field 
values, causing incorrect results for independently constructed equal rows.

Affected functions:
 * {{ARRAY_CONTAINS}}
 * {{ARRAY_POSITION}}
 * {{ARRAY_REMOVE}}
 * {{ARRAY_DISTINCT}}
 * {{ARRAY_UNION}}
 * {{ARRAY_INTERSECT}}
 * {{ARRAY_EXCEPT}}
 * {{ARRAYS_OVERLAP}}

The issue also affects nested rows, such as {{ROW(ROW(...), ...)}} and 
{{{}ROW(ARRAY[ROW(...)], ...){}}}.

Example:
{code:java}
SELECT ARRAY_CONTAINS(ARRAY[ROW(x, y)], ROW(z, w))
FROM (VALUES
  (1, 'Foo', 1, 'Foo'),
  (2, 'Bar', 2, 'Bar')
) AS t(x, y, z, w);{code}
Expected: {{true}} for both rows. Actual: {{false}} for both rows.

Nested {{ROW}} values are also affected. Constant expressions may mask the 
issue.



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

Reply via email to