diff --git a/dbms/src/Columns/ColumnArray.cpp b/dbms/src/Columns/ColumnArray.cpp index bc835df09db..1b85dae1741 100644 --- a/dbms/src/Columns/ColumnArray.cpp +++ b/dbms/src/Columns/ColumnArray.cpp @@ -341,6 +341,25 @@ void ColumnArray::getExtremes(Field & min, Field & max) const { min = Array(); max = Array(); + + size_t col_size = size(); + + if (col_size == 0) + return; + + size_t min_idx = 0; + size_t max_idx = 0; + + for (size_t i = 1; i < col_size; ++i) + { + if (compareAt(i, min_idx, *this, /* nan_direction_hint = */ 1) < 0) + min_idx = i; + if (compareAt(i, max_idx, *this, /* nan_direction_hint = */ -1) > 0) + max_idx = i; + } + + get(min_idx, min); + get(max_idx, max); } diff --git a/dbms/src/Columns/ColumnFixedString.cpp b/dbms/src/Columns/ColumnFixedString.cpp index ad846d45603..61ab24fee10 100644 --- a/dbms/src/Columns/ColumnFixedString.cpp +++ b/dbms/src/Columns/ColumnFixedString.cpp @@ -289,6 +289,27 @@ void ColumnFixedString::getExtremes(Field & min, Field & max) const { min = String(); max = String(); + + size_t col_size = size(); + + if (col_size == 0) + return; + + size_t min_idx = 0; + size_t max_idx = 0; + + less less_op(*this); + + for (size_t i = 1; i < col_size; ++i) + { + if (less_op(i, min_idx)) + min_idx = i; + if (less_op(max_idx, i)) + max_idx = i; + } + + get(min_idx, min); + get(max_idx, max); } } diff --git a/dbms/src/Columns/ColumnString.cpp b/dbms/src/Columns/ColumnString.cpp index 17fb9b53667..5a04db5d893 100644 --- a/dbms/src/Columns/ColumnString.cpp +++ b/dbms/src/Columns/ColumnString.cpp @@ -265,6 +265,27 @@ void ColumnString::getExtremes(Field & min, Field & max) const { min = String(); max = String(); + + size_t col_size = size(); + + if (col_size == 0) + return; + + size_t min_idx = 0; + size_t max_idx = 0; + + less less_op(*this); + + for (size_t i = 1; i < col_size; ++i) + { + if (less_op(i, min_idx)) + min_idx = i; + if (less_op(max_idx, i)) + max_idx = i; + } + + get(min_idx, min); + get(max_idx, max); } diff --git a/dbms/tests/queries/0_stateless/00307_format_xml.reference b/dbms/tests/queries/0_stateless/00307_format_xml.reference index c439e6db932..2d9badc5a3e 100644 --- a/dbms/tests/queries/0_stateless/00307_format_xml.reference +++ b/dbms/tests/queries/0_stateless/00307_format_xml.reference @@ -36,18 +36,20 @@ - - + Hello & world + Hello +<World> - - 2001-02-03 04:05:06 + 0123456789 + Hello & world2001-02-03 04:05:06 - - + Hello & world + Hello +<World> - - 2001-02-03 04:05:06 + 0123456789 + Hello & world2001-02-03 04:05:06 1 diff --git a/dbms/tests/queries/0_stateless/00378_json_quote_64bit_integers.reference b/dbms/tests/queries/0_stateless/00378_json_quote_64bit_integers.reference index 8240d0b21f6..22395188fe6 100644 --- a/dbms/tests/queries/0_stateless/00378_json_quote_64bit_integers.reference +++ b/dbms/tests/queries/0_stateless/00378_json_quote_64bit_integers.reference @@ -64,7 +64,7 @@ "ip": "9223372036854775807", "in": "-9223372036854775808", "up": "18446744073709551615", - "arr": [], + "arr": ["0"], "tuple": ["0","0"] }, "max": @@ -74,7 +74,7 @@ "ip": "9223372036854775807", "in": "-9223372036854775808", "up": "18446744073709551615", - "arr": [], + "arr": ["0"], "tuple": ["0","0"] } }, @@ -123,8 +123,8 @@ "extremes": { - "min": ["0","0","9223372036854775807","-9223372036854775808","18446744073709551615",[],["0","0"]], - "max": ["0","0","9223372036854775807","-9223372036854775808","18446744073709551615",[],["0","0"]] + "min": ["0","0","9223372036854775807","-9223372036854775808","18446744073709551615",["0"],["0","0"]], + "max": ["0","0","9223372036854775807","-9223372036854775808","18446744073709551615",["0"],["0","0"]] }, "rows": 1 @@ -196,7 +196,7 @@ "ip": 9223372036854775807, "in": -9223372036854775808, "up": 18446744073709551615, - "arr": [], + "arr": [0], "tuple": [0,0] }, "max": @@ -206,7 +206,7 @@ "ip": 9223372036854775807, "in": -9223372036854775808, "up": 18446744073709551615, - "arr": [], + "arr": [0], "tuple": [0,0] } }, @@ -255,8 +255,8 @@ "extremes": { - "min": [0,0,9223372036854775807,-9223372036854775808,18446744073709551615,[],[0,0]], - "max": [0,0,9223372036854775807,-9223372036854775808,18446744073709551615,[],[0,0]] + "min": [0,0,9223372036854775807,-9223372036854775808,18446744073709551615,[0],[0,0]], + "max": [0,0,9223372036854775807,-9223372036854775808,18446744073709551615,[0],[0,0]] }, "rows": 1