From 9e1d8b8aaa438d7280c10f966102fab2aa1ae46b Mon Sep 17 00:00:00 2001 From: Antonio Andelic Date: Thu, 4 Apr 2024 15:22:09 +0200 Subject: [PATCH] Fix mortonEncode with no rows --- src/Functions/mortonEncode.cpp | 3 +++ .../queries/0_stateless/03035_morton_encode_no_rows.reference | 2 ++ tests/queries/0_stateless/03035_morton_encode_no_rows.sql | 2 ++ 3 files changed, 7 insertions(+) create mode 100644 tests/queries/0_stateless/03035_morton_encode_no_rows.reference create mode 100644 tests/queries/0_stateless/03035_morton_encode_no_rows.sql diff --git a/src/Functions/mortonEncode.cpp b/src/Functions/mortonEncode.cpp index fee14c7784b..3b95c114b14 100644 --- a/src/Functions/mortonEncode.cpp +++ b/src/Functions/mortonEncode.cpp @@ -321,6 +321,9 @@ public: ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type, size_t input_rows_count) const override { + if (input_rows_count == 0) + return ColumnUInt64::create(); + return selector.selectAndExecute(arguments, result_type, input_rows_count); } diff --git a/tests/queries/0_stateless/03035_morton_encode_no_rows.reference b/tests/queries/0_stateless/03035_morton_encode_no_rows.reference new file mode 100644 index 00000000000..dc8bb19a028 --- /dev/null +++ b/tests/queries/0_stateless/03035_morton_encode_no_rows.reference @@ -0,0 +1,2 @@ +4294967286 +4294967286 diff --git a/tests/queries/0_stateless/03035_morton_encode_no_rows.sql b/tests/queries/0_stateless/03035_morton_encode_no_rows.sql new file mode 100644 index 00000000000..2663b1ac212 --- /dev/null +++ b/tests/queries/0_stateless/03035_morton_encode_no_rows.sql @@ -0,0 +1,2 @@ +SELECT mortonEncode(materialize((1, 1)), 65534, 65533); +SELECT mortonEncode((1, 1), 65534, 65533);