From 7237343fd63527fe1bdd5e734012e980e7391c19 Mon Sep 17 00:00:00 2001 From: Anton Popov Date: Fri, 26 Nov 2021 17:39:03 +0300 Subject: [PATCH] fix function 'empty' with uuid type --- src/Functions/EmptyImpl.h | 2 +- tests/queries/0_stateless/02124_empty_uuid.reference | 4 ++++ tests/queries/0_stateless/02124_empty_uuid.sql | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tests/queries/0_stateless/02124_empty_uuid.reference create mode 100644 tests/queries/0_stateless/02124_empty_uuid.sql diff --git a/src/Functions/EmptyImpl.h b/src/Functions/EmptyImpl.h index c3117e0e52d..60daa66ea03 100644 --- a/src/Functions/EmptyImpl.h +++ b/src/Functions/EmptyImpl.h @@ -58,7 +58,7 @@ struct EmptyImpl static void uuid(const ColumnUUID::Container & container, size_t n, PaddedPODArray & res) { for (size_t i = 0; i < n; ++i) - res[i] = negative ^ (container.data()->toUnderType() == 0); + res[i] = negative ^ (container[i].toUnderType() == 0); } }; diff --git a/tests/queries/0_stateless/02124_empty_uuid.reference b/tests/queries/0_stateless/02124_empty_uuid.reference new file mode 100644 index 00000000000..31c1ccfc7ca --- /dev/null +++ b/tests/queries/0_stateless/02124_empty_uuid.reference @@ -0,0 +1,4 @@ +00000000-0000-0000-0000-000000000000 1 +992f6910-42b2-43cd-98bc-c812fbf9b683 0 +992f6910-42b2-43cd-98bc-c812fbf9b683 0 +00000000-0000-0000-0000-000000000000 1 diff --git a/tests/queries/0_stateless/02124_empty_uuid.sql b/tests/queries/0_stateless/02124_empty_uuid.sql new file mode 100644 index 00000000000..8dbfa3bae27 --- /dev/null +++ b/tests/queries/0_stateless/02124_empty_uuid.sql @@ -0,0 +1,7 @@ +SELECT + arrayJoin([toUUID('00000000-0000-0000-0000-000000000000'), toUUID('992f6910-42b2-43cd-98bc-c812fbf9b683')]) AS x, + empty(x) AS emp; + +SELECT + arrayJoin([toUUID('992f6910-42b2-43cd-98bc-c812fbf9b683'), toUUID('00000000-0000-0000-0000-000000000000')]) AS x, + empty(x) AS emp;