Repository navigation
Only use Field::safeGet - Field::get prone to type punning - #68135
Conversation
|
This is an automated comment for commit 5c8665c with description of existing statuses. It's updated for the latest CI running ✅ Click here to open a full report in a separate page Successful checks
|
| std::erase_if(tuple, [&](auto & child) | ||
| auto & tuple = tuple_literal->value.safeGet<Tuple>(); | ||
| if (tuple.size() > 1) | ||
| { | ||
| return tuple.size() > 1 && !shardContains(child, name, data); | ||
| }); | ||
| Tuple new_tuple; | ||
|
|
||
| for (auto & child : tuple) | ||
| if (shardContains(child, name, data)) | ||
| new_tuple.emplace_back(std::move(child)); | ||
|
|
||
| if (new_tuple.empty()) | ||
| new_tuple.emplace_back(std::move(tuple.back())); | ||
|
|
||
| tuple_literal->value = std::move(new_tuple); | ||
| } |
There was a problem hiding this comment.
original tuple.size() > 1 will not work in std::erase_if - refactored
| { | ||
| res = AggregateFunctionStateData(); | ||
| res.get<AggregateFunctionStateData &>().name = type_string; | ||
| { | ||
| WriteBufferFromString buffer(res.get<AggregateFunctionStateData &>().data); | ||
| func->serialize(data[n], buffer, version); | ||
| } | ||
| res = operator[](n); | ||
| } |
There was a problem hiding this comment.
duplicated code - refactored
| if (which_type.isDate() && which_from_type.isDateTime()) | ||
| { | ||
| return static_cast<UInt16>(static_cast<const DataTypeDateTime &>(*from_type_hint).getTimeZone().toDayNum(src.get<UInt64>()).toUnderType()); | ||
| return static_cast<UInt16>(static_cast<const DataTypeDateTime &>(*from_type_hint).getTimeZone().toDayNum(src.safeGet<UInt64>()).toUnderType()); |
There was a problem hiding this comment.
bug found due to this PR - fix Field conversion to IPv4
| auto & num_rebalance_assigments = assert_cast<ColumnUInt64 &>(*res_columns[index++]); | ||
| auto & is_currently_used = assert_cast<ColumnUInt8 &>(*res_columns[index++]); | ||
| auto & last_used = assert_cast<ColumnDateTime64 &>(*res_columns[index++]); | ||
| auto & last_used = assert_cast<ColumnUInt64 &>(*res_columns[index++]); |
There was a problem hiding this comment.
bug found due to this PR - incorrect column type
|
@rschu1ze this is pretty simple PR despite apparent size - relevant changes - Field::get moved to private, Field::safeGet cleaned up (supposedly), all calls to Field::get outside of Field replaced by Field::safeGet. Couple other fixes are simple and annotated. |
| /// This function is prone to type punning and should never be used outside of Field class, | ||
| /// whenever it is used within this class the stored type should be checked in advance. | ||
| template <typename T> | ||
| NearestFieldType<std::decay_t<T>> & get() |
There was a problem hiding this comment.
What about naming
getasget_unsafe(orunsafeGet),- and
safeGetasget
?
There was a problem hiding this comment.
I thought about this (and it would be much easier refactoring), but I decided that it's better to left it more obvious so whoever uses it would be aware that get is not that simple...
* [GLUTEN-1632][CH]Daily Update Clickhouse Version (20240815) * Fix Build due to ClickHouse/ClickHouse#68107 * Fix Build due to ClickHouse/ClickHouse#68135 * Fix UT due to ClickHouse/ClickHouse#68135 * Add ut for #2584 - Rebase failed with ClickHouse/ClickHouse#67879, and hence we can remove Kyligence/ClickHouse#454 (cherry picked from commit 583aa8d6566a9e1c0924c1a3ab1d315fcc229fa6) * Fix CH BUG due to ClickHouse/ClickHouse#68135 see Kyligence/ClickHouse@d87dbba * Resolve conflict --------- Co-authored-by: kyligence-git <[email protected]> Co-authored-by: Chang Chen <[email protected]>
) * [GLUTEN-1632][CH]Daily Update Clickhouse Version (20240815) * Fix Build due to ClickHouse/ClickHouse#68107 * Fix Build due to ClickHouse/ClickHouse#68135 * Fix UT due to ClickHouse/ClickHouse#68135 * Add ut for apache#2584 - Rebase failed with ClickHouse/ClickHouse#67879, and hence we can remove Kyligence/ClickHouse#454 (cherry picked from commit 583aa8d6566a9e1c0924c1a3ab1d315fcc229fa6) * Fix CH BUG due to ClickHouse/ClickHouse#68135 see Kyligence/ClickHouse@d87dbba * Resolve conflict --------- Co-authored-by: kyligence-git <[email protected]> Co-authored-by: Chang Chen <[email protected]>
* Add aggregation function for Largest-Triangle-Three-Buckets (#53145) * Added a simple lttb aggregate function * Added support for multiple datatypes * Added support for Date and Date32, updated LTTBData struct * Updated code to handle bucket size 0 and 1 * Added sort for LTTBData * Added tests and documentation * Added some code style fixes * Added function to new func ref file * Removed function from new func ref file * Apply suggestions from code review * Updated unit tests * updated LTTB data code * Minor style fixes * Updated code with std sort * updated tests * Renamed lttb to largestTriangleThreeBuckets * Added alias lttb --------- Co-authored-by: Alexey Milovidov <[email protected]> * ClickHouse/ClickHouse#56350 (partial) * fix: split lttb bucket strategy, first bucket and last bucket should only contain single point (#57003) * fix: split lttb bucket policy, first bucket and last bucket should only contain single point * add comments and modify the corresponding query test * style: update code format * style: remove useless comments * feat: add lttb bucket size test * fix: typo, duplicate sql * Merge pull request #62646 from Algunenano/i_like_triangles Fix crash in largestTriangleThreeBuckets * ClickHouse/ClickHouse#60469 (partial) * ClickHouse/ClickHouse#68135 (partial) * Merge pull request #73172 from ucasfl/fix-ubsan Fix UBSAN in largestTriangleThreeBuckets * fixes --------- Co-authored-by: Sinan <[email protected]> Co-authored-by: Alexey Milovidov <[email protected]> Co-authored-by: FFish <[email protected]> Co-authored-by: Raúl Marín <[email protected]> Co-authored-by: Yarik Briukhovetskyi <[email protected]>
* Add aggregation function for Largest-Triangle-Three-Buckets (#53145) * Added a simple lttb aggregate function * Added support for multiple datatypes * Added support for Date and Date32, updated LTTBData struct * Updated code to handle bucket size 0 and 1 * Added sort for LTTBData * Added tests and documentation * Added some code style fixes * Added function to new func ref file * Removed function from new func ref file * Apply suggestions from code review * Updated unit tests * updated LTTB data code * Minor style fixes * Updated code with std sort * updated tests * Renamed lttb to largestTriangleThreeBuckets * Added alias lttb --------- Co-authored-by: Alexey Milovidov <[email protected]> * ClickHouse/ClickHouse#56350 (partial) * fix: split lttb bucket strategy, first bucket and last bucket should only contain single point (#57003) * fix: split lttb bucket policy, first bucket and last bucket should only contain single point * add comments and modify the corresponding query test * style: update code format * style: remove useless comments * feat: add lttb bucket size test * fix: typo, duplicate sql * Merge pull request #62646 from Algunenano/i_like_triangles Fix crash in largestTriangleThreeBuckets * ClickHouse/ClickHouse#60469 (partial) * ClickHouse/ClickHouse#68135 (partial) * Merge pull request #73172 from ucasfl/fix-ubsan Fix UBSAN in largestTriangleThreeBuckets * fixes
* Add aggregation function for Largest-Triangle-Three-Buckets (#53145) * Added a simple lttb aggregate function * Added support for multiple datatypes * Added support for Date and Date32, updated LTTBData struct * Updated code to handle bucket size 0 and 1 * Added sort for LTTBData * Added tests and documentation * Added some code style fixes * Added function to new func ref file * Removed function from new func ref file * Apply suggestions from code review * Updated unit tests * updated LTTB data code * Minor style fixes * Updated code with std sort * updated tests * Renamed lttb to largestTriangleThreeBuckets * Added alias lttb --------- Co-authored-by: Alexey Milovidov <[email protected]> * ClickHouse/ClickHouse#56350 (partial) * fix: split lttb bucket strategy, first bucket and last bucket should only contain single point (#57003) * fix: split lttb bucket policy, first bucket and last bucket should only contain single point * add comments and modify the corresponding query test * style: update code format * style: remove useless comments * feat: add lttb bucket size test * fix: typo, duplicate sql * Merge pull request #62646 from Algunenano/i_like_triangles Fix crash in largestTriangleThreeBuckets * ClickHouse/ClickHouse#60469 (partial) * ClickHouse/ClickHouse#68135 (partial) * Merge pull request #73172 from ucasfl/fix-ubsan Fix UBSAN in largestTriangleThreeBuckets * fixes
Changelog category (leave one):
CI Settings (Only check the boxes if you know what you are doing):