mirror of
https://github.com/apache/impala.git
synced 2026-01-04 09:00:56 -05:00
This patch changes the resolution of overloaded functions so that we prefer functions where there is no loss of precision in argument types. Previously, the logic would happily convert DECIMAL to FLOAT even if there was a more suitable overload available. E.g. greatest(TINYINT, DECIMAL) was resolved to greatest(FLOAT...) instead of greatest(DECIMAL). This only changes behaviour when no overload exactly matches the argument types, but the arguments can be converted with no loss of precision, e.g. TINYINT to DECIMAL. This patch introduces a conceptual distinction between strict and non-strict compatibility. All contexts aside from function matching use non-strict to support the current behavior of implicitly casting decimals to floats/doubles. This patch also makes resolution of overloaded functions consistent regardless of what order functions were added to the Db - overloads are checked in a canonical order. Switching to this canonical order revealed further problems with overload resolution where the correct overload was selected only because of the order in which it was added to the database. For example, the logic equally preferred resolving fn(STRING, TINYINT) to fn(TIMESTAMP, INT) or fn(STRING, INT). This required changes to the compatibility matrix. Various cleanup and simplification of the type compatibility logic is also included. Change-Id: I50e657c78cdcb925b616b5b088b801510020e255 Reviewed-on: http://gerrit.cloudera.org:8080/845 Reviewed-by: Tim Armstrong <tarmstrong@cloudera.com> Tested-by: Internal Jenkins
9.5 KiB
9.5 KiB