From 1062e6316f951a6fef837ae76f1269dba8a736e8 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Mon, 18 Nov 2024 01:35:03 +0100 Subject: [PATCH 1/2] Fix cast --- CHANGELOG.md | 2 +- base/base/bit_cast.h | 4 +- base/base/wide_integer_impl.h | 2 +- .../aspell-ignore/en/aspell-dict.txt | 2 - docs/changelogs/v23.10.1.1976-stable.md | 2 +- docs/changelogs/v23.2.1.2537-stable.md | 2 +- docs/changelogs/v24.8.1.2684-lts.md | 3 +- docs/changelogs/v24.9.1.3278-stable.md | 3 +- docs/en/sql-reference/data-types/map.md | 2 +- docs/en/sql-reference/data-types/newjson.md | 2 +- .../functions/arithmetic-functions.md | 2 +- .../functions/tuple-map-functions.md | 4 +- .../functions/type-conversion-functions.md | 4 +- .../statements/alter/constraint.md | 2 +- .../sql-reference/statements/alter/update.md | 2 +- .../ExternalDictionaryLibraryAPI.h | 2 +- .../AggregateFunctionMLMethod.h | 2 +- src/Analyzer/Resolve/IdentifierResolveScope.h | 2 +- src/Columns/ColumnObjectDeprecated.cpp | 10 +-- src/Columns/IColumn.h | 6 +- src/Common/LocalDate.h | 2 +- src/Common/LocalDateTime.h | 2 +- src/Common/StringSearcher.h | 6 +- src/Common/waitForPid.cpp | 2 +- src/Coordination/KeeperServer.cpp | 10 +-- src/Core/SortDescription.h | 2 +- src/DataTypes/NumberTraits.h | 2 +- src/DataTypes/Utils.cpp | 18 ++--- src/DataTypes/Utils.h | 4 +- src/DataTypes/getLeastSupertype.h | 4 +- .../MySQL/MaterializedMySQLSyncThread.cpp | 74 +++++++++---------- src/Dictionaries/IDictionary.h | 4 +- src/Dictionaries/PolygonDictionary.cpp | 4 +- src/Formats/ProtobufSerializer.cpp | 24 +++--- src/Functions/DivisionUtils.h | 2 +- src/Functions/FunctionDynamicAdaptor.cpp | 2 +- src/Functions/FunctionsConversion.cpp | 52 ++++++------- src/Functions/FunctionsExternalDictionaries.h | 18 ++--- src/Functions/array/arrayIntersect.cpp | 26 +++---- src/Functions/array/arrayShiftRotate.cpp | 8 +- src/Functions/neighbor.cpp | 30 ++++---- src/Functions/parseDateTime.cpp | 8 +- src/Functions/transform.cpp | 60 +++++++-------- src/Functions/widthBucket.cpp | 18 ++--- src/Interpreters/ActionsDAG.cpp | 8 +- src/Interpreters/ActionsDAG.h | 6 +- src/Interpreters/AddDefaultDatabaseVisitor.h | 2 +- src/Interpreters/TableJoin.cpp | 4 +- .../evaluateConstantExpression.cpp | 8 +- src/Interpreters/getColumnFromBlock.cpp | 4 +- src/Loggers/OwnSplitChannel.h | 2 +- src/Parsers/IAST.h | 12 +-- src/Processors/Transforms/WindowTransform.cpp | 6 +- src/Processors/Transforms/WindowTransform.h | 2 +- src/Storages/ColumnsDescription.h | 2 +- src/Storages/MergeTree/KeyCondition.cpp | 12 +-- .../MergeTreeSplitPrewhereIntoReadSteps.cpp | 4 +- .../00298_enum_width_and_cast.reference | 10 +-- .../0_stateless/00298_enum_width_and_cast.sql | 2 +- .../01655_plan_optimizations.reference | 4 +- .../0_stateless/01655_plan_optimizations.sh | 4 +- .../aspell-ignore/en/aspell-dict.txt | 2 - 62 files changed, 265 insertions(+), 271 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dacee73440f..945ff69301b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -344,7 +344,7 @@ * The system table `text_log` is enabled by default. This is fully compatible with previous versions, but you may notice subtly increased disk usage on the local disk (this system table takes a tiny amount of disk space). [#67428](https://github.com/ClickHouse/ClickHouse/pull/67428) ([Alexey Milovidov](https://github.com/alexey-milovidov)). * In previous versions, `arrayWithConstant` can be slow if asked to generate very large arrays. In the new version, it is limited to 1 GB per array. This closes [#32754](https://github.com/ClickHouse/ClickHouse/issues/32754). [#67741](https://github.com/ClickHouse/ClickHouse/pull/67741) ([Alexey Milovidov](https://github.com/alexey-milovidov)). * Fix REPLACE modifier formatting (forbid omitting brackets). [#67774](https://github.com/ClickHouse/ClickHouse/pull/67774) ([Azat Khuzhin](https://github.com/azat)). -* Backported in [#68349](https://github.com/ClickHouse/ClickHouse/issues/68349): Reimplement `Dynamic` type. Now when the limit of dynamic data types is reached new types are not casted to String but stored in a special data structure in binary format with binary encoded data type. Now any type ever inserted into `Dynamic` column can be read from it as subcolumn. [#68132](https://github.com/ClickHouse/ClickHouse/pull/68132) ([Kruglov Pavel](https://github.com/Avogar)). +* Backported in [#68349](https://github.com/ClickHouse/ClickHouse/issues/68349): Reimplement `Dynamic` type. Now when the limit of dynamic data types is reached new types are not cast to String but stored in a special data structure in binary format with binary encoded data type. Now any type ever inserted into `Dynamic` column can be read from it as subcolumn. [#68132](https://github.com/ClickHouse/ClickHouse/pull/68132) ([Kruglov Pavel](https://github.com/Avogar)). #### New Feature * Added a new `MergeTree` setting `deduplicate_merge_projection_mode` to control the projections during merges (for specific engines) and `OPTIMIZE DEDUPLICATE` query. Supported options: `throw` (throw an exception in case the projection is not fully supported for *MergeTree engine), `drop` (remove projection during merge if it can't be merged itself consistently) and `rebuild` (rebuild projection from scratch, which is a heavy operation). [#66672](https://github.com/ClickHouse/ClickHouse/pull/66672) ([jsc0218](https://github.com/jsc0218)). diff --git a/base/base/bit_cast.h b/base/base/bit_cast.h index 9a92b7660f1..b10c8f9ee82 100644 --- a/base/base/bit_cast.h +++ b/base/base/bit_cast.h @@ -11,9 +11,9 @@ * * In contrast to std::bit_cast can cast types of different width. * - * Note: for signed types of narrower size, the casted result is zero-extended + * Note: for signed types of narrower size, the cast result is zero-extended * instead of sign-extended as with regular static_cast. - * For example, -1 Int8 (represented as 0xFF) bit_casted to UInt64 + * For example, -1 Int8 (represented as 0xFF) bit_cast to UInt64 * gives 255 (represented as 0x00000000000000FF) instead of 0xFFFFFFFFFFFFFFFF */ template diff --git a/base/base/wide_integer_impl.h b/base/base/wide_integer_impl.h index 3787971a20e..712ffbc321c 100644 --- a/base/base/wide_integer_impl.h +++ b/base/base/wide_integer_impl.h @@ -337,7 +337,7 @@ struct integer::_impl /** Here we have to use strict comparison. * The max_int is 2^64 - 1. - * When casted to floating point type, it will be rounded to the closest representable number, + * When cast to a floating point type, it will be rounded to the closest representable number, * which is 2^64. * But 2^64 is not representable in uint64_t, * so the maximum representable number will be strictly less. diff --git a/ci/jobs/scripts/check_style/aspell-ignore/en/aspell-dict.txt b/ci/jobs/scripts/check_style/aspell-ignore/en/aspell-dict.txt index 7cae8509b83..bb2b85976b2 100644 --- a/ci/jobs/scripts/check_style/aspell-ignore/en/aspell-dict.txt +++ b/ci/jobs/scripts/check_style/aspell-ignore/en/aspell-dict.txt @@ -1316,7 +1316,6 @@ bools boringssl boundingRatio bozerkins -broadcasted brotli bson bsoneachrow @@ -1342,7 +1341,6 @@ cardinalities cardinality cartesian cassandra -casted catboost catboostEvaluate categoricalInformationValue diff --git a/docs/changelogs/v23.10.1.1976-stable.md b/docs/changelogs/v23.10.1.1976-stable.md index 4d093f934f1..4da8bf1e256 100644 --- a/docs/changelogs/v23.10.1.1976-stable.md +++ b/docs/changelogs/v23.10.1.1976-stable.md @@ -56,7 +56,7 @@ sidebar_label: 2023 #### Improvement * This is the second part of Kusto Query Language dialect support. [Phase 1 implementation ](https://github.com/ClickHouse/ClickHouse/pull/37961) has been merged. [#42510](https://github.com/ClickHouse/ClickHouse/pull/42510) ([larryluogit](https://github.com/larryluogit)). -* Op processors IDs are raw ptrs casted to UInt64. Print it in a prettier manner:. [#48852](https://github.com/ClickHouse/ClickHouse/pull/48852) ([Vlad Seliverstov](https://github.com/behebot)). +* Op processors IDs are raw ptrs cast to UInt64. Print it in a prettier manner:. [#48852](https://github.com/ClickHouse/ClickHouse/pull/48852) ([Vlad Seliverstov](https://github.com/behebot)). * Creating a direct dictionary with a lifetime field set will be rejected at create time. Fixes: [#27861](https://github.com/ClickHouse/ClickHouse/issues/27861). [#49043](https://github.com/ClickHouse/ClickHouse/pull/49043) ([Rory Crispin](https://github.com/RoryCrispin)). * Allow parameters in queries with partitions like `ALTER TABLE t DROP PARTITION`. Closes [#49449](https://github.com/ClickHouse/ClickHouse/issues/49449). [#49516](https://github.com/ClickHouse/ClickHouse/pull/49516) ([Nikolay Degterinsky](https://github.com/evillique)). * 1.Refactor the code about zookeeper_connection 2.Add a new column xid for zookeeper_connection. [#50702](https://github.com/ClickHouse/ClickHouse/pull/50702) ([helifu](https://github.com/helifu)). diff --git a/docs/changelogs/v23.2.1.2537-stable.md b/docs/changelogs/v23.2.1.2537-stable.md index 9da81c039ea..87e6210728c 100644 --- a/docs/changelogs/v23.2.1.2537-stable.md +++ b/docs/changelogs/v23.2.1.2537-stable.md @@ -73,7 +73,7 @@ sidebar_label: 2023 * ``` sumIf(123, cond) -> 123 * countIf(1, cond) sum(if(cond, 123, 0)) -> 123 * countIf(cond) sum(if(cond, 0, 123)) -> 123 * countIf(not(cond)) ```. [#44728](https://github.com/ClickHouse/ClickHouse/pull/44728) ([李扬](https://github.com/taiyang-li)). * Optimize behavior for a replica delay api logic in case the replica is read-only. [#45148](https://github.com/ClickHouse/ClickHouse/pull/45148) ([mateng915](https://github.com/mateng0915)). * Introduce gwp-asan implemented by llvm runtime. This closes [#27039](https://github.com/ClickHouse/ClickHouse/issues/27039). [#45226](https://github.com/ClickHouse/ClickHouse/pull/45226) ([Han Fei](https://github.com/hanfei1991)). -* ... in the case key casted from uint64 to uint32, small impact for little endian platform but key value becomes zero in big endian case. ### Documentation entry for user-facing changes. [#45375](https://github.com/ClickHouse/ClickHouse/pull/45375) ([Suzy Wang](https://github.com/SuzyWangIBMer)). +* ... in the case key cast from uint64 to uint32, small impact for little endian platform but key value becomes zero in big endian case. ### Documentation entry for user-facing changes. [#45375](https://github.com/ClickHouse/ClickHouse/pull/45375) ([Suzy Wang](https://github.com/SuzyWangIBMer)). * Mark Gorilla compression on columns of non-Float* type as suspicious. [#45376](https://github.com/ClickHouse/ClickHouse/pull/45376) ([Robert Schulze](https://github.com/rschu1ze)). * Allow removing redundant aggregation keys with constants (e.g., simplify `GROUP BY a, a + 1` to `GROUP BY a`). [#45415](https://github.com/ClickHouse/ClickHouse/pull/45415) ([Dmitry Novik](https://github.com/novikd)). * Show replica name that is executing a merge in the postpone_reason. [#45458](https://github.com/ClickHouse/ClickHouse/pull/45458) ([Frank Chen](https://github.com/FrankChen021)). diff --git a/docs/changelogs/v24.8.1.2684-lts.md b/docs/changelogs/v24.8.1.2684-lts.md index 8171bb3d719..607ba92cb53 100644 --- a/docs/changelogs/v24.8.1.2684-lts.md +++ b/docs/changelogs/v24.8.1.2684-lts.md @@ -15,7 +15,7 @@ sidebar_label: 2024 * The system table `text_log` is enabled by default. This is fully compatible with previous versions, but you may notice subtly increased disk usage on the local disk (this system table takes a tiny amount of disk space). [#67428](https://github.com/ClickHouse/ClickHouse/pull/67428) ([Alexey Milovidov](https://github.com/alexey-milovidov)). * In previous versions, `arrayWithConstant` can be slow if asked to generate very large arrays. In the new version, it is limited to 1 GB per array. This closes [#32754](https://github.com/ClickHouse/ClickHouse/issues/32754). [#67741](https://github.com/ClickHouse/ClickHouse/pull/67741) ([Alexey Milovidov](https://github.com/alexey-milovidov)). * Fix REPLACE modifier formatting (forbid omitting brackets). [#67774](https://github.com/ClickHouse/ClickHouse/pull/67774) ([Azat Khuzhin](https://github.com/azat)). -* Backported in [#68349](https://github.com/ClickHouse/ClickHouse/issues/68349): Reimplement Dynamic type. Now when the limit of dynamic data types is reached new types are not casted to String but stored in a special data structure in binary format with binary encoded data type. Now any type ever inserted into Dynamic column can be read from it as subcolumn. [#68132](https://github.com/ClickHouse/ClickHouse/pull/68132) ([Kruglov Pavel](https://github.com/Avogar)). +* Backported in [#68349](https://github.com/ClickHouse/ClickHouse/issues/68349): Reimplement Dynamic type. Now when the limit of dynamic data types is reached new types are not cast to String but stored in a special data structure in binary format with binary encoded data type. Now any type ever inserted into Dynamic column can be read from it as subcolumn. [#68132](https://github.com/ClickHouse/ClickHouse/pull/68132) ([Kruglov Pavel](https://github.com/Avogar)). #### New Feature * Add new experimental Kafka storage engine to store offsets in Keeper instead of relying on committing them to Kafka. [#57625](https://github.com/ClickHouse/ClickHouse/pull/57625) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). @@ -522,4 +522,3 @@ sidebar_label: 2024 * Backported in [#68518](https://github.com/ClickHouse/ClickHouse/issues/68518): Minor update in Dynamic/JSON serializations. [#68459](https://github.com/ClickHouse/ClickHouse/pull/68459) ([Kruglov Pavel](https://github.com/Avogar)). * Backported in [#68558](https://github.com/ClickHouse/ClickHouse/issues/68558): CI: Minor release workflow fix. [#68536](https://github.com/ClickHouse/ClickHouse/pull/68536) ([Max K.](https://github.com/maxknv)). * Backported in [#68576](https://github.com/ClickHouse/ClickHouse/issues/68576): CI: Tidy build timeout from 2h to 3h. [#68567](https://github.com/ClickHouse/ClickHouse/pull/68567) ([Max K.](https://github.com/maxknv)). - diff --git a/docs/changelogs/v24.9.1.3278-stable.md b/docs/changelogs/v24.9.1.3278-stable.md index 0489f5ae454..687bbc9e5c4 100644 --- a/docs/changelogs/v24.9.1.3278-stable.md +++ b/docs/changelogs/v24.9.1.3278-stable.md @@ -10,7 +10,7 @@ sidebar_label: 2024 #### Backward Incompatible Change * Allow to write `SETTINGS` before `FORMAT` in a chain of queries with `UNION` when subqueries are inside parentheses. This closes [#39712](https://github.com/ClickHouse/ClickHouse/issues/39712). Change the behavior when a query has the SETTINGS clause specified twice in a sequence. The closest SETTINGS clause will have a preference for the corresponding subquery. In the previous versions, the outermost SETTINGS clause could take a preference over the inner one. [#60197](https://github.com/ClickHouse/ClickHouse/pull/60197) ([Alexey Milovidov](https://github.com/alexey-milovidov)). * Do not allow explicitly specifying UUID when creating a table in Replicated database. Also, do not allow explicitly specifying ZooKeeper path and replica name for *MergeTree tables in Replicated databases. [#66104](https://github.com/ClickHouse/ClickHouse/pull/66104) ([Alexander Tokmakov](https://github.com/tavplubix)). -* Reimplement Dynamic type. Now when the limit of dynamic data types is reached new types are not casted to String but stored in a special data structure in binary format with binary encoded data type. Now any type ever inserted into Dynamic column can be read from it as subcolumn. [#68132](https://github.com/ClickHouse/ClickHouse/pull/68132) ([Pavel Kruglov](https://github.com/Avogar)). +* Reimplement Dynamic type. Now when the limit of dynamic data types is reached new types are not cast to String but stored in a special data structure in binary format with binary encoded data type. Now any type ever inserted into Dynamic column can be read from it as subcolumn. [#68132](https://github.com/ClickHouse/ClickHouse/pull/68132) ([Pavel Kruglov](https://github.com/Avogar)). * Expressions like `a[b].c` are supported for named tuples, as well as named subscripts from arbitrary expressions, e.g., `expr().name`. This is useful for processing JSON. This closes [#54965](https://github.com/ClickHouse/ClickHouse/issues/54965). In previous versions, an expression of form `expr().name` was parsed as `tupleElement(expr(), name)`, and the query analyzer was searching for a column `name` rather than for the corresponding tuple element; while in the new version, it is changed to `tupleElement(expr(), 'name')`. In most cases, the previous version was not working, but it is possible to imagine a very unusual scenario when this change could lead to incompatibility: if you stored names of tuple elements in a column or an alias, that was named differently than the tuple element's name: `SELECT 'b' AS a, CAST([tuple(123)] AS 'Array(Tuple(b UInt8))') AS t, t[1].a`. It is very unlikely that you used such queries, but we still have to mark this change as potentially backward incompatible. [#68435](https://github.com/ClickHouse/ClickHouse/pull/68435) ([Alexey Milovidov](https://github.com/alexey-milovidov)). * When the setting `print_pretty_type_names` is enabled, it will print `Tuple` data type in a pretty form in `SHOW CREATE TABLE` statements, `formatQuery` function, and in the interactive mode in `clickhouse-client` and `clickhouse-local`. In previous versions, this setting was only applied to `DESCRIBE` queries and `toTypeName`. This closes [#65753](https://github.com/ClickHouse/ClickHouse/issues/65753). [#68492](https://github.com/ClickHouse/ClickHouse/pull/68492) ([Alexey Milovidov](https://github.com/alexey-milovidov)). @@ -497,4 +497,3 @@ sidebar_label: 2024 * Backported in [#69899](https://github.com/ClickHouse/ClickHouse/issues/69899): Revert "Merge pull request [#69032](https://github.com/ClickHouse/ClickHouse/issues/69032) from alexon1234/include_real_time_execution_in_http_header". [#69885](https://github.com/ClickHouse/ClickHouse/pull/69885) ([Alexey Milovidov](https://github.com/alexey-milovidov)). * Backported in [#69931](https://github.com/ClickHouse/ClickHouse/issues/69931): RIPE is an acronym and thus should be capital. RIPE stands for **R**ACE **I**ntegrity **P**rimitives **E**valuation and RACE stands for **R**esearch and Development in **A**dvanced **C**ommunications **T**echnologies in **E**urope. [#69901](https://github.com/ClickHouse/ClickHouse/pull/69901) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). * Backported in [#70034](https://github.com/ClickHouse/ClickHouse/issues/70034): Revert "Add RIPEMD160 function". [#70005](https://github.com/ClickHouse/ClickHouse/pull/70005) ([Robert Schulze](https://github.com/rschu1ze)). - diff --git a/docs/en/sql-reference/data-types/map.md b/docs/en/sql-reference/data-types/map.md index 9f82c2f093a..2a6347b293a 100644 --- a/docs/en/sql-reference/data-types/map.md +++ b/docs/en/sql-reference/data-types/map.md @@ -64,7 +64,7 @@ Result: ## Converting Tuple to Map -Values of type `Tuple()` can be casted to values of type `Map()` using function [CAST](../../sql-reference/functions/type-conversion-functions.md#type_conversion_function-cast): +Values of type `Tuple()` can be cast to values of type `Map()` using function [CAST](../../sql-reference/functions/type-conversion-functions.md#type_conversion_function-cast): **Example** diff --git a/docs/en/sql-reference/data-types/newjson.md b/docs/en/sql-reference/data-types/newjson.md index 4a21900545d..05197d9e692 100644 --- a/docs/en/sql-reference/data-types/newjson.md +++ b/docs/en/sql-reference/data-types/newjson.md @@ -187,7 +187,7 @@ select json.a.g.:Float64, dynamicType(json.a.g), json.d.:Date, dynamicType(json. └─────────────────────┴───────────────────────┴────────────────┴─────────────────────┘ ``` -`Dynamic` subcolumns can be casted to any data type. In this case the exception will be thrown if internal type inside `Dynamic` cannot be casted to the requested type: +`Dynamic` subcolumns can be cast to any data type. In this case the exception will be thrown if internal type inside `Dynamic` cannot be cast to the requested type: ```sql select json.a.g::UInt64 as uint FROM test; diff --git a/docs/en/sql-reference/functions/arithmetic-functions.md b/docs/en/sql-reference/functions/arithmetic-functions.md index e3fb1d91c05..e57358c1e36 100644 --- a/docs/en/sql-reference/functions/arithmetic-functions.md +++ b/docs/en/sql-reference/functions/arithmetic-functions.md @@ -8,7 +8,7 @@ sidebar_label: Arithmetic Arithmetic functions work for any two operands of type `UInt8`, `UInt16`, `UInt32`, `UInt64`, `Int8`, `Int16`, `Int32`, `Int64`, `Float32`, or `Float64`. -Before performing the operation, both operands are casted to the result type. The result type is determined as follows (unless specified +Before performing the operation, both operands are cast to the result type. The result type is determined as follows (unless specified differently in the function documentation below): - If both operands are up to 32 bits wide, the size of the result type will be the size of the next bigger type following the bigger of the two operands (integer size promotion). For example, `UInt8 + UInt16 = UInt32` or `Float32 * Float32 = Float64`. diff --git a/docs/en/sql-reference/functions/tuple-map-functions.md b/docs/en/sql-reference/functions/tuple-map-functions.md index d670ed42a2a..107a11fe6d6 100644 --- a/docs/en/sql-reference/functions/tuple-map-functions.md +++ b/docs/en/sql-reference/functions/tuple-map-functions.md @@ -85,7 +85,7 @@ Result: └───────────────────────────────────────────┘ ``` -`mapFromArrays` also accepts arguments of type [Map](../data-types/map.md). These are casted to array of tuples during execution. +`mapFromArrays` also accepts arguments of type [Map](../data-types/map.md). These are cast to array of tuples during execution. ```sql SELECT mapFromArrays([1, 2, 3], map('a', 1, 'b', 2, 'c', 3)) @@ -936,4 +936,4 @@ SELECT mapPartialReverseSort((k, v) -> v, 2, map('k1', 3, 'k2', 1, 'k3', 2)); ┌─mapPartialReverseSort(lambda(tuple(k, v), v), 2, map('k1', 3, 'k2', 1, 'k3', 2))─┐ │ {'k1':3,'k3':2,'k2':1} │ └──────────────────────────────────────────────────────────────────────────────────┘ -``` \ No newline at end of file +``` diff --git a/docs/en/sql-reference/functions/type-conversion-functions.md b/docs/en/sql-reference/functions/type-conversion-functions.md index 5f4c59f5218..875dbaf9b6a 100644 --- a/docs/en/sql-reference/functions/type-conversion-functions.md +++ b/docs/en/sql-reference/functions/type-conversion-functions.md @@ -6257,7 +6257,7 @@ Code: 70. DB::Exception: Received from localhost:9000. DB::Exception: Value in c ## accurateCastOrNull(x, T) -Converts input value `x` to the specified data type `T`. Always returns [Nullable](../data-types/nullable.md) type and returns [NULL](../syntax.md/#null-literal) if the casted value is not representable in the target type. +Converts input value `x` to the specified data type `T`. Always returns [Nullable](../data-types/nullable.md) type and returns [NULL](../syntax.md/#null-literal) if the cast value is not representable in the target type. **Syntax** @@ -6310,7 +6310,7 @@ Result: ## accurateCastOrDefault(x, T[, default_value]) -Converts input value `x` to the specified data type `T`. Returns default type value or `default_value` if specified if the casted value is not representable in the target type. +Converts input value `x` to the specified data type `T`. Returns default type value or `default_value` if specified if the cast value is not representable in the target type. **Syntax** diff --git a/docs/en/sql-reference/statements/alter/constraint.md b/docs/en/sql-reference/statements/alter/constraint.md index 54c456f9aa2..0dd0cc24d4e 100644 --- a/docs/en/sql-reference/statements/alter/constraint.md +++ b/docs/en/sql-reference/statements/alter/constraint.md @@ -21,4 +21,4 @@ Queries will add or remove metadata about constraints from table, so they are pr Constraint check **will not be executed** on existing data if it was added. ::: -All changes on replicated tables are broadcasted to ZooKeeper and will be applied on other replicas as well. +All changes on replicated tables are broadcast to ZooKeeper and will be applied on other replicas as well. diff --git a/docs/en/sql-reference/statements/alter/update.md b/docs/en/sql-reference/statements/alter/update.md index 0b300e5849a..04ef8c68e31 100644 --- a/docs/en/sql-reference/statements/alter/update.md +++ b/docs/en/sql-reference/statements/alter/update.md @@ -16,7 +16,7 @@ Manipulates data matching the specified filtering expression. Implemented as a [ The `ALTER TABLE` prefix makes this syntax different from most other systems supporting SQL. It is intended to signify that unlike similar queries in OLTP databases this is a heavy operation not designed for frequent use. ::: -The `filter_expr` must be of type `UInt8`. This query updates values of specified columns to the values of corresponding expressions in rows for which the `filter_expr` takes a non-zero value. Values are casted to the column type using the `CAST` operator. Updating columns that are used in the calculation of the primary or the partition key is not supported. +The `filter_expr` must be of type `UInt8`. This query updates values of specified columns to the values of corresponding expressions in rows for which the `filter_expr` takes a non-zero value. Values are cast to the column type using the `CAST` operator. Updating columns that are used in the calculation of the primary or the partition key is not supported. One query can contain several commands separated by commas. diff --git a/programs/library-bridge/ExternalDictionaryLibraryAPI.h b/programs/library-bridge/ExternalDictionaryLibraryAPI.h index 04201710edb..8a14a721a5b 100644 --- a/programs/library-bridge/ExternalDictionaryLibraryAPI.h +++ b/programs/library-bridge/ExternalDictionaryLibraryAPI.h @@ -68,7 +68,7 @@ struct ExternalDictionaryLibraryAPI using LibrarySettings = CStrings *; using LibraryData = void *; using RawClickHouseLibraryTable = void *; - /// Can be safely casted into const Table * with static_cast + /// Can be safely cast into const Table * with static_cast using RequestedColumnsNames = CStrings *; using RequestedIds = const VectorUInt64 *; using RequestedKeys = Table *; diff --git a/src/AggregateFunctions/AggregateFunctionMLMethod.h b/src/AggregateFunctions/AggregateFunctionMLMethod.h index cfb8550d829..84aac19d2ae 100644 --- a/src/AggregateFunctions/AggregateFunctionMLMethod.h +++ b/src/AggregateFunctions/AggregateFunctionMLMethod.h @@ -384,7 +384,7 @@ public: auto * column = typeid_cast(&to); if (!column) throw Exception(ErrorCodes::LOGICAL_ERROR, "Cast of column of predictions is incorrect. " - "getReturnTypeToPredict must return same value as it is casted to"); + "getReturnTypeToPredict must return same value as it is cast to"); this->data(place).predict(column->getData(), arguments, offset, limit, context); } diff --git a/src/Analyzer/Resolve/IdentifierResolveScope.h b/src/Analyzer/Resolve/IdentifierResolveScope.h index ab2e27cc14d..9a09c645189 100644 --- a/src/Analyzer/Resolve/IdentifierResolveScope.h +++ b/src/Analyzer/Resolve/IdentifierResolveScope.h @@ -174,7 +174,7 @@ struct IdentifierResolveScope size_t found_nullable_group_by_key_in_scope = 0; /** It's possible that after a JOIN, a column in the projection has a type different from the column in the source table. - * (For example, after join_use_nulls or USING column casted to supertype) + * (For example, after join_use_nulls or USING column cast to supertype) * However, the column in the projection still refers to the table as its source. * This map is used to revert these columns back to their original columns in the source table. */ diff --git a/src/Columns/ColumnObjectDeprecated.cpp b/src/Columns/ColumnObjectDeprecated.cpp index d03b1d0df82..bd0b26d659f 100644 --- a/src/Columns/ColumnObjectDeprecated.cpp +++ b/src/Columns/ColumnObjectDeprecated.cpp @@ -392,14 +392,14 @@ void ColumnObjectDeprecated::Subcolumn::insertRangeFrom(const Subcolumn & src, s if (n * 3 >= column->size()) { - auto casted_column = castColumn({column, column_type, ""}, least_common_type.get()); - data.back()->insertRangeFrom(*casted_column, from, n); + auto cast_column = castColumn({column, column_type, ""}, least_common_type.get()); + data.back()->insertRangeFrom(*cast_column, from, n); return; } - auto casted_column = column->cut(from, n); - casted_column = castColumn({casted_column, column_type, ""}, least_common_type.get()); - data.back()->insertRangeFrom(*casted_column, 0, n); + auto cast_column = column->cut(from, n); + cast_column = castColumn({cast_column, column_type, ""}, least_common_type.get()); + data.back()->insertRangeFrom(*cast_column, 0, n); }; size_t pos = 0; diff --git a/src/Columns/IColumn.h b/src/Columns/IColumn.h index c77b089812e..983f1d9fb80 100644 --- a/src/Columns/IColumn.h +++ b/src/Columns/IColumn.h @@ -156,7 +156,7 @@ public: throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Method get64 is not supported for {}", getName()); } - /// If column stores native numeric type, it returns n-th element casted to Float64 + /// If column stores native numeric type, it returns n-th element cast to Float64 /// Is used in regression methods to cast each features into uniform type [[nodiscard]] virtual Float64 getFloat64(size_t /*n*/) const { @@ -168,7 +168,7 @@ public: throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Method getFloat32 is not supported for {}", getName()); } - /** If column is numeric, return value of n-th element, casted to UInt64. + /** If column is numeric, return value of n-th element, cast to UInt64. * For NULL values of Nullable column it is allowed to return arbitrary value. * Otherwise throw an exception. */ @@ -185,7 +185,7 @@ public: [[nodiscard]] virtual bool isDefaultAt(size_t n) const = 0; [[nodiscard]] virtual bool isNullAt(size_t /*n*/) const { return false; } - /** If column is numeric, return value of n-th element, casted to bool. + /** If column is numeric, return value of n-th element, cast to bool. * For NULL values of Nullable column returns false. * Otherwise throw an exception. */ diff --git a/src/Common/LocalDate.h b/src/Common/LocalDate.h index f1abc98c8e2..94e0dd1572e 100644 --- a/src/Common/LocalDate.h +++ b/src/Common/LocalDate.h @@ -10,7 +10,7 @@ /** Stores a calendar date in broken-down form (year, month, day-in-month). * Could be initialized from date in text form, like '2011-01-01' or from time_t with rounding to date. * Also could be initialized from date in text form like '20110101... (only first 8 symbols are used). - * Could be implicitly casted to time_t. + * Could be implicitly cast to time_t. * NOTE: Transforming between time_t and LocalDate is done in local time zone! * * When local time was shifted backwards (due to daylight saving time or whatever reason) diff --git a/src/Common/LocalDateTime.h b/src/Common/LocalDateTime.h index 1aa4f421ea1..74c51a74a16 100644 --- a/src/Common/LocalDateTime.h +++ b/src/Common/LocalDateTime.h @@ -9,7 +9,7 @@ /** Stores calendar date and time in broken-down form. * Could be initialized from date and time in text form like '2011-01-01 00:00:00' or from time_t. - * Could be implicitly casted to time_t. + * Could be implicitly cast to time_t. * NOTE: Transforming between time_t and LocalDate is done in local time zone! * * When local time was shifted backwards (due to daylight saving time or whatever reason) diff --git a/src/Common/StringSearcher.h b/src/Common/StringSearcher.h index d7e706fcd80..5a296113a8c 100644 --- a/src/Common/StringSearcher.h +++ b/src/Common/StringSearcher.h @@ -66,7 +66,7 @@ private: #ifdef __SSE4_1__ /// second character of "needle" (if its length is > 1) uint8_t second_needle_character = 0; - /// first/second needle character broadcasted into a 16 bytes vector + /// first/second needle character broadcast into a 16 bytes vector __m128i first_needle_character_vec; __m128i second_needle_character_vec; /// vector of first 16 characters of `needle` @@ -204,8 +204,8 @@ public: while (haystack < haystack_end && haystack_end - haystack >= needle_size) { #ifdef __SSE4_1__ - /// Compare the [0:15] bytes from haystack and broadcasted 16 bytes vector from first character of needle. - /// Compare the [1:16] bytes from haystack and broadcasted 16 bytes vector from second character of needle. + /// Compare the [0:15] bytes from haystack and broadcast 16 bytes vector from first character of needle. + /// Compare the [1:16] bytes from haystack and broadcast 16 bytes vector from second character of needle. /// Bit AND the results of above two comparisons and get the mask. if ((haystack + 1 + N) <= haystack_end && isPageSafe(haystack + 1)) { diff --git a/src/Common/waitForPid.cpp b/src/Common/waitForPid.cpp index c5940402d46..f846658d8c6 100644 --- a/src/Common/waitForPid.cpp +++ b/src/Common/waitForPid.cpp @@ -182,7 +182,7 @@ bool waitForPid(pid_t pid, size_t timeout_in_seconds) /// If timeout is positive try waitpid without block in loop until /// process is normally terminated or waitpid return error - /// NOTE: timeout casted to int, since poll() accept int for timeout + /// NOTE: timeout cast to int, since poll() accept int for timeout int timeout_in_ms = static_cast(timeout_in_seconds * 1000); while (timeout_in_ms > 0) { diff --git a/src/Coordination/KeeperServer.cpp b/src/Coordination/KeeperServer.cpp index f5f11e10a84..205a2f407a6 100644 --- a/src/Coordination/KeeperServer.cpp +++ b/src/Coordination/KeeperServer.cpp @@ -514,12 +514,12 @@ void KeeperServer::launchRaftServer(const Poco::Util::AbstractConfiguration & co nuraft::ptr scheduler = asio_service; nuraft::ptr rpc_cli_factory = asio_service; - nuraft::ptr casted_state_manager = state_manager; - nuraft::ptr casted_state_machine = state_machine; + nuraft::ptr cast_state_manager = state_manager; + nuraft::ptr cast_state_machine = state_machine; /// raft_server creates unique_ptr from it nuraft::context * ctx - = new nuraft::context(casted_state_manager, casted_state_machine, asio_listeners, logger, rpc_cli_factory, scheduler, params); + = new nuraft::context(cast_state_manager, cast_state_machine, asio_listeners, logger, rpc_cli_factory, scheduler, params); raft_instance = nuraft::cs_new(ctx, init_options); @@ -535,11 +535,11 @@ void KeeperServer::launchRaftServer(const Poco::Util::AbstractConfiguration & co raft_instance->start_server(init_options.skip_initial_election_timeout_); - nuraft::ptr casted_raft_server = raft_instance; + nuraft::ptr cast_raft_server = raft_instance; for (const auto & asio_listener : asio_listeners) { - asio_listener->listen(casted_raft_server); + asio_listener->listen(cast_raft_server); } } diff --git a/src/Core/SortDescription.h b/src/Core/SortDescription.h index 7a7c92f3b53..522732dad90 100644 --- a/src/Core/SortDescription.h +++ b/src/Core/SortDescription.h @@ -120,7 +120,7 @@ using SortDescriptionWithPositions = std::vector { public: - /// Can be safely casted into JITSortDescriptionFunc + /// Can be safely cast into JITSortDescriptionFunc void * compiled_sort_description = nullptr; std::shared_ptr compiled_sort_description_holder; size_t min_count_to_compile_sort_description = 3; diff --git a/src/DataTypes/NumberTraits.h b/src/DataTypes/NumberTraits.h index ee0d9812097..5f5962da5ee 100644 --- a/src/DataTypes/NumberTraits.h +++ b/src/DataTypes/NumberTraits.h @@ -205,7 +205,7 @@ struct ResultOfIf ConstructedType, Error>>>; }; -/** Before applying operator `%` and bitwise operations, operands are casted to whole numbers. */ +/** Before applying operator `%` and bitwise operations, operands are cast to whole numbers. */ template struct ToInteger { using Type = typename Construct< diff --git a/src/DataTypes/Utils.cpp b/src/DataTypes/Utils.cpp index 3004322475c..e626f7da957 100644 --- a/src/DataTypes/Utils.cpp +++ b/src/DataTypes/Utils.cpp @@ -9,7 +9,7 @@ namespace DB { -bool canBeSafelyCasted(const DataTypePtr & from_type, const DataTypePtr & to_type) +bool canBeSafelyCast(const DataTypePtr & from_type, const DataTypePtr & to_type) { auto from_which_type = WhichDataType(from_type->getTypeId()); bool to_type_was_nullable = isNullableOrLowCardinalityNullable(to_type); @@ -127,7 +127,7 @@ bool canBeSafelyCasted(const DataTypePtr & from_type, const DataTypePtr & to_typ if (to_type_was_nullable) { const auto & from_type_nullable = assert_cast(*from_type); - return canBeSafelyCasted(from_type_nullable.getNestedType(), to_type_unwrapped); + return canBeSafelyCast(from_type_nullable.getNestedType(), to_type_unwrapped); } if (to_which_type.isString()) @@ -138,7 +138,7 @@ bool canBeSafelyCasted(const DataTypePtr & from_type, const DataTypePtr & to_typ case TypeIndex::LowCardinality: { const auto & from_type_low_cardinality = assert_cast(*from_type); - return canBeSafelyCasted(from_type_low_cardinality.getDictionaryType(), to_type_unwrapped); + return canBeSafelyCast(from_type_low_cardinality.getDictionaryType(), to_type_unwrapped); } case TypeIndex::Array: { @@ -146,7 +146,7 @@ bool canBeSafelyCasted(const DataTypePtr & from_type, const DataTypePtr & to_typ { const auto & from_type_array = assert_cast(*from_type); const auto & to_type_array = assert_cast(*to_type_unwrapped); - return canBeSafelyCasted(from_type_array.getNestedType(), to_type_array.getNestedType()); + return canBeSafelyCast(from_type_array.getNestedType(), to_type_array.getNestedType()); } if (to_which_type.isString()) @@ -160,10 +160,10 @@ bool canBeSafelyCasted(const DataTypePtr & from_type, const DataTypePtr & to_typ { const auto & from_type_map = assert_cast(*from_type); const auto & to_type_map = assert_cast(*to_type_unwrapped); - if (!canBeSafelyCasted(from_type_map.getKeyType(), to_type_map.getKeyType())) + if (!canBeSafelyCast(from_type_map.getKeyType(), to_type_map.getKeyType())) return false; - if (!canBeSafelyCasted(from_type_map.getValueType(), to_type_map.getValueType())) + if (!canBeSafelyCast(from_type_map.getValueType(), to_type_map.getValueType())) return false; return true; @@ -182,10 +182,10 @@ bool canBeSafelyCasted(const DataTypePtr & from_type, const DataTypePtr & to_typ if (to_type_tuple_elements.size() != 2) return false; - if (!canBeSafelyCasted(from_type_map.getKeyType(), to_type_tuple_elements[0])) + if (!canBeSafelyCast(from_type_map.getKeyType(), to_type_tuple_elements[0])) return false; - if (!canBeSafelyCasted(from_type_map.getValueType(), to_type_tuple_elements[1])) + if (!canBeSafelyCast(from_type_map.getValueType(), to_type_tuple_elements[1])) return false; return true; @@ -211,7 +211,7 @@ bool canBeSafelyCasted(const DataTypePtr & from_type, const DataTypePtr & to_typ return false; for (size_t i = 0; i < lhs_type_elements_size; ++i) - if (!canBeSafelyCasted(from_tuple_type_elements[i], to_tuple_type_elements[i])) + if (!canBeSafelyCast(from_tuple_type_elements[i], to_tuple_type_elements[i])) return false; return true; diff --git a/src/DataTypes/Utils.h b/src/DataTypes/Utils.h index bee109f4524..0535db5087e 100644 --- a/src/DataTypes/Utils.h +++ b/src/DataTypes/Utils.h @@ -5,7 +5,7 @@ namespace DB { -/** Returns true if from_type can be safely casted to to_type. +/** Returns true if from_type can be safely cast to to_type. * * Examples: * From type UInt8 to type UInt16 returns true. @@ -14,6 +14,6 @@ namespace DB * From type LowCardinality(String) to type String returns true. * From type String to type UInt8 returns false. */ -bool canBeSafelyCasted(const DataTypePtr & from_type, const DataTypePtr & to_type); +bool canBeSafelyCast(const DataTypePtr & from_type, const DataTypePtr & to_type); } diff --git a/src/DataTypes/getLeastSupertype.h b/src/DataTypes/getLeastSupertype.h index 55d8e8fff0d..8d9d75fd759 100644 --- a/src/DataTypes/getLeastSupertype.h +++ b/src/DataTypes/getLeastSupertype.h @@ -24,11 +24,11 @@ template DataTypePtr getLeastSupertype(const DataTypes & types); /// Same as above but return String type instead of throwing exception. -/// All types can be casted to String, because they can be serialized to String. +/// All types can be cast to String, because they can be serialized to String. DataTypePtr getLeastSupertypeOrString(const DataTypes & types); /// Same as getLeastSupertype but in case when there is no supertype for provided types -/// it uses Variant of these types as a supertype. Any type can be casted to a Variant +/// it uses Variant of these types as a supertype. Any type can be cast to a Variant /// that contains this type. /// As nested Variants are not allowed, if one of the types is Variant, it's variants /// are used in the resulting Variant. diff --git a/src/Databases/MySQL/MaterializedMySQLSyncThread.cpp b/src/Databases/MySQL/MaterializedMySQLSyncThread.cpp index 389d7a58b86..e495e9fe03e 100644 --- a/src/Databases/MySQL/MaterializedMySQLSyncThread.cpp +++ b/src/Databases/MySQL/MaterializedMySQLSyncThread.cpp @@ -750,7 +750,7 @@ static void writeFieldsToColumn( return true; }; - const auto & write_data_to_column = [&](auto * casted_column, auto from_type, auto to_type) + const auto & write_data_to_column = [&](auto * cast_column, auto from_type, auto to_type) { for (size_t index = 0; index < rows_data.size(); ++index) { @@ -758,39 +758,39 @@ static void writeFieldsToColumn( const Field & value = row_data[column_index]; if (write_data_to_null_map(value, index)) - casted_column->insertValue(static_cast(value.template safeGet())); + cast_column->insertValue(static_cast(value.template safeGet())); } }; - if (ColumnInt8 * casted_int8_column = typeid_cast(&column_to)) - write_data_to_column(casted_int8_column, UInt64(), Int8()); - else if (ColumnInt16 * casted_int16_column = typeid_cast(&column_to)) - write_data_to_column(casted_int16_column, UInt64(), Int16()); - else if (ColumnInt64 * casted_int64_column = typeid_cast(&column_to)) - write_data_to_column(casted_int64_column, UInt64(), Int64()); - else if (ColumnUInt8 * casted_uint8_column = typeid_cast(&column_to)) - write_data_to_column(casted_uint8_column, UInt64(), UInt8()); - else if (ColumnUInt16 * casted_uint16_column = typeid_cast(&column_to)) - write_data_to_column(casted_uint16_column, UInt64(), UInt16()); - else if (ColumnUInt32 * casted_uint32_column = typeid_cast(&column_to)) - write_data_to_column(casted_uint32_column, UInt64(), UInt32()); - else if (ColumnUInt64 * casted_uint64_column = typeid_cast(&column_to)) - write_data_to_column(casted_uint64_column, UInt64(), UInt64()); - else if (ColumnFloat32 * casted_float32_column = typeid_cast(&column_to)) - write_data_to_column(casted_float32_column, Float64(), Float32()); - else if (ColumnFloat64 * casted_float64_column = typeid_cast(&column_to)) - write_data_to_column(casted_float64_column, Float64(), Float64()); - else if (ColumnDecimal * casted_decimal_32_column = typeid_cast *>(&column_to)) - write_data_to_column(casted_decimal_32_column, Decimal32(), Decimal32()); - else if (ColumnDecimal * casted_decimal_64_column = typeid_cast *>(&column_to)) - write_data_to_column(casted_decimal_64_column, Decimal64(), Decimal64()); - else if (ColumnDecimal * casted_decimal_128_column = typeid_cast *>(&column_to)) - write_data_to_column(casted_decimal_128_column, Decimal128(), Decimal128()); - else if (ColumnDecimal * casted_decimal_256_column = typeid_cast *>(&column_to)) - write_data_to_column(casted_decimal_256_column, Decimal256(), Decimal256()); - else if (ColumnDecimal * casted_datetime_64_column = typeid_cast *>(&column_to)) - write_data_to_column(casted_datetime_64_column, DateTime64(), DateTime64()); - else if (ColumnInt32 * casted_int32_column = typeid_cast(&column_to)) + if (ColumnInt8 * cast_int8_column = typeid_cast(&column_to)) + write_data_to_column(cast_int8_column, UInt64(), Int8()); + else if (ColumnInt16 * cast_int16_column = typeid_cast(&column_to)) + write_data_to_column(cast_int16_column, UInt64(), Int16()); + else if (ColumnInt64 * cast_int64_column = typeid_cast(&column_to)) + write_data_to_column(cast_int64_column, UInt64(), Int64()); + else if (ColumnUInt8 * cast_uint8_column = typeid_cast(&column_to)) + write_data_to_column(cast_uint8_column, UInt64(), UInt8()); + else if (ColumnUInt16 * cast_uint16_column = typeid_cast(&column_to)) + write_data_to_column(cast_uint16_column, UInt64(), UInt16()); + else if (ColumnUInt32 * cast_uint32_column = typeid_cast(&column_to)) + write_data_to_column(cast_uint32_column, UInt64(), UInt32()); + else if (ColumnUInt64 * cast_uint64_column = typeid_cast(&column_to)) + write_data_to_column(cast_uint64_column, UInt64(), UInt64()); + else if (ColumnFloat32 * cast_float32_column = typeid_cast(&column_to)) + write_data_to_column(cast_float32_column, Float64(), Float32()); + else if (ColumnFloat64 * cast_float64_column = typeid_cast(&column_to)) + write_data_to_column(cast_float64_column, Float64(), Float64()); + else if (ColumnDecimal * cast_decimal_32_column = typeid_cast *>(&column_to)) + write_data_to_column(cast_decimal_32_column, Decimal32(), Decimal32()); + else if (ColumnDecimal * cast_decimal_64_column = typeid_cast *>(&column_to)) + write_data_to_column(cast_decimal_64_column, Decimal64(), Decimal64()); + else if (ColumnDecimal * cast_decimal_128_column = typeid_cast *>(&column_to)) + write_data_to_column(cast_decimal_128_column, Decimal128(), Decimal128()); + else if (ColumnDecimal * cast_decimal_256_column = typeid_cast *>(&column_to)) + write_data_to_column(cast_decimal_256_column, Decimal256(), Decimal256()); + else if (ColumnDecimal * cast_datetime_64_column = typeid_cast *>(&column_to)) + write_data_to_column(cast_datetime_64_column, DateTime64(), DateTime64()); + else if (ColumnInt32 * cast_int32_column = typeid_cast(&column_to)) { for (size_t index = 0; index < rows_data.size(); ++index) { @@ -800,19 +800,19 @@ static void writeFieldsToColumn( if (write_data_to_null_map(value, index)) { if (value.getType() == Field::Types::UInt64) - casted_int32_column->insertValue(static_cast(value.safeGet())); + cast_int32_column->insertValue(static_cast(value.safeGet())); else if (value.getType() == Field::Types::Int64) { /// For MYSQL_TYPE_INT24 const Int32 & num = static_cast(value.safeGet()); - casted_int32_column->insertValue(num & 0x800000 ? num | 0xFF000000 : num); + cast_int32_column->insertValue(num & 0x800000 ? num | 0xFF000000 : num); } else throw Exception(ErrorCodes::LOGICAL_ERROR, "MaterializedMySQL is a bug."); } } } - else if (ColumnString * casted_string_column = typeid_cast(&column_to)) + else if (ColumnString * cast_string_column = typeid_cast(&column_to)) { for (size_t index = 0; index < rows_data.size(); ++index) { @@ -822,11 +822,11 @@ static void writeFieldsToColumn( if (write_data_to_null_map(value, index)) { const String & data = value.safeGet(); - casted_string_column->insertData(data.data(), data.size()); + cast_string_column->insertData(data.data(), data.size()); } } } - else if (ColumnFixedString * casted_fixed_string_column = typeid_cast(&column_to)) + else if (ColumnFixedString * cast_fixed_string_column = typeid_cast(&column_to)) { for (size_t index = 0; index < rows_data.size(); ++index) { @@ -836,7 +836,7 @@ static void writeFieldsToColumn( if (write_data_to_null_map(value, index)) { const String & data = value.safeGet(); - casted_fixed_string_column->insertData(data.data(), data.size()); + cast_fixed_string_column->insertData(data.data(), data.size()); } } } diff --git a/src/Dictionaries/IDictionary.h b/src/Dictionaries/IDictionary.h index c8a79709bfa..7f550e3a5c2 100644 --- a/src/Dictionaries/IDictionary.h +++ b/src/Dictionaries/IDictionary.h @@ -163,8 +163,8 @@ public: auto & key_column_to_cast = key_columns[key_attribute_type_index]; ColumnWithTypeAndName column_to_cast = {key_column_to_cast, key_type, ""}; - auto casted_column = castColumnAccurate(column_to_cast, key_attribute_type); - key_column_to_cast = std::move(casted_column); + auto cast_column = castColumnAccurate(column_to_cast, key_attribute_type); + key_column_to_cast = std::move(cast_column); key_type = key_attribute_type; } } diff --git a/src/Dictionaries/PolygonDictionary.cpp b/src/Dictionaries/PolygonDictionary.cpp index 0f99d0b7f7a..3919d4ef21f 100644 --- a/src/Dictionaries/PolygonDictionary.cpp +++ b/src/Dictionaries/PolygonDictionary.cpp @@ -62,8 +62,8 @@ void IPolygonDictionary::convertKeyColumns(Columns & key_columns, DataTypes & ke auto & key_column_to_cast = key_columns[key_type_index]; ColumnWithTypeAndName column_to_cast = {key_column_to_cast, key_type, ""}; - auto casted_column = castColumnAccurate(column_to_cast, float_64_type); - key_column_to_cast = std::move(casted_column); + auto cast_column = castColumnAccurate(column_to_cast, float_64_type); + key_column_to_cast = std::move(cast_column); key_type = float_64_type; } } diff --git a/src/Formats/ProtobufSerializer.cpp b/src/Formats/ProtobufSerializer.cpp index bd8aeff5a5d..be9d7e47cab 100644 --- a/src/Formats/ProtobufSerializer.cpp +++ b/src/Formats/ProtobufSerializer.cpp @@ -227,33 +227,33 @@ namespace template void writeInt(NumberType value) { - auto casted = castNumber(value); - if (casted != 0 || !skip_zero_or_empty) - writer->writeInt(field_tag, casted); + auto cast = castNumber(value); + if (cast != 0 || !skip_zero_or_empty) + writer->writeInt(field_tag, cast); } template void writeSInt(NumberType value) { - auto casted = castNumber(value); - if (casted != 0 || !skip_zero_or_empty) - writer->writeSInt(field_tag, casted); + auto cast = castNumber(value); + if (cast != 0 || !skip_zero_or_empty) + writer->writeSInt(field_tag, cast); } template void writeUInt(NumberType value) { - auto casted = castNumber(value); - if (casted != 0 || !skip_zero_or_empty) - writer->writeUInt(field_tag, casted); + auto cast = castNumber(value); + if (cast != 0 || !skip_zero_or_empty) + writer->writeUInt(field_tag, cast); } template void writeFixed(NumberType value) { - auto casted = castNumber(value); - if (casted != 0 || !skip_zero_or_empty) - writer->writeFixed(field_tag, casted); + auto cast = castNumber(value); + if (cast != 0 || !skip_zero_or_empty) + writer->writeFixed(field_tag, cast); } Int64 readInt() { return reader->readInt(); } diff --git a/src/Functions/DivisionUtils.h b/src/Functions/DivisionUtils.h index e8f5da342f8..1d9c2ad7ccb 100644 --- a/src/Functions/DivisionUtils.h +++ b/src/Functions/DivisionUtils.h @@ -84,7 +84,7 @@ struct DivideIntegralImpl } else { - /// Comparisons are not strict to avoid rounding issues when operand is implicitly casted to float. + /// Comparisons are not strict to avoid rounding issues when operand is implicitly cast to float. if constexpr (is_floating_point) if (isNaN(a) || a >= std::numeric_limits::max() || a <= std::numeric_limits::lowest()) diff --git a/src/Functions/FunctionDynamicAdaptor.cpp b/src/Functions/FunctionDynamicAdaptor.cpp index 9d63328006d..8f119fd7bb8 100644 --- a/src/Functions/FunctionDynamicAdaptor.cpp +++ b/src/Functions/FunctionDynamicAdaptor.cpp @@ -206,7 +206,7 @@ ColumnPtr ExecutableFunctionDynamicAdaptor::executeImpl(const ColumnsWithTypeAnd nested_result_type = result_type; } - /// If the result of nested function is Dynamic (or we casted to it from Variant), we can just expand it + /// If the result of nested function is Dynamic (or we cast to it from Variant), we can just expand it /// and cast to the result Dynamic type (it can have different max_types parameter). if (isDynamic(nested_result_type)) { diff --git a/src/Functions/FunctionsConversion.cpp b/src/Functions/FunctionsConversion.cpp index d581ae510e8..cb516c98d4f 100644 --- a/src/Functions/FunctionsConversion.cpp +++ b/src/Functions/FunctionsConversion.cpp @@ -4206,7 +4206,7 @@ private: { try { - /// We can avoid try/catch here if we will implement check that 2 types can be casted, but it + /// We can avoid try/catch here if we will implement check that 2 types can be cast, but it /// requires quite a lot of work. By now let's simply use try/catch. /// First, check that we can create a wrapper. WrapperType wrapper = prepareUnpackDictionaries(from, to); @@ -4252,31 +4252,31 @@ private: const auto & column_variant = assert_cast(*arguments.front().column.get()); /// First, cast each variant to the result type. - std::vector casted_variant_columns; - casted_variant_columns.reserve(variant_types.size()); + std::vector cast_variant_columns; + cast_variant_columns.reserve(variant_types.size()); for (size_t i = 0; i != variant_types.size(); ++i) { auto variant_col = column_variant.getVariantPtrByGlobalDiscriminator(i); ColumnsWithTypeAndName variant = {{variant_col, variant_types[i], "" }}; const auto & variant_wrapper = variant_wrappers[i]; - ColumnPtr casted_variant; + ColumnPtr cast_variant; /// Check if we have wrapper for this variant. if (variant_wrapper) - casted_variant = variant_wrapper(variant, result_type, nullptr, variant_col->size()); - casted_variant_columns.push_back(std::move(casted_variant)); + cast_variant = variant_wrapper(variant, result_type, nullptr, variant_col->size()); + cast_variant_columns.push_back(std::move(cast_variant)); } - /// Second, construct resulting column from casted variant columns according to discriminators. + /// Second, construct resulting column from cast variant columns according to discriminators. const auto & local_discriminators = column_variant.getLocalDiscriminators(); auto res = result_type->createColumn(); res->reserve(input_rows_count); for (size_t i = 0; i != input_rows_count; ++i) { auto global_discr = column_variant.globalDiscriminatorByLocal(local_discriminators[i]); - if (global_discr == ColumnVariant::NULL_DISCRIMINATOR || !casted_variant_columns[global_discr]) + if (global_discr == ColumnVariant::NULL_DISCRIMINATOR || !cast_variant_columns[global_discr]) res->insertDefault(); else - res->insertFrom(*casted_variant_columns[global_discr], column_variant.offsetAt(i)); + res->insertFrom(*cast_variant_columns[global_discr], column_variant.offsetAt(i)); } return res; @@ -4459,14 +4459,14 @@ private: /// First, cast usual variants to result type. const auto & variant_types = assert_cast(*variant_info.variant_type).getVariants(); - std::vector casted_variant_columns; - casted_variant_columns.reserve(variant_types.size()); + std::vector cast_variant_columns; + cast_variant_columns.reserve(variant_types.size()); for (size_t i = 0; i != variant_types.size(); ++i) { /// Skip shared variant, it will be processed later. if (i == column_dynamic.getSharedVariantDiscriminator()) { - casted_variant_columns.push_back(nullptr); + cast_variant_columns.push_back(nullptr); continue; } @@ -4479,11 +4479,11 @@ private: else variant_wrapper = prepareUnpackDictionaries(variant_types[i], result_type); - ColumnPtr casted_variant; + ColumnPtr cast_variant; /// Check if we have wrapper for this variant. if (variant_wrapper) - casted_variant = variant_wrapper(variant, result_type, nullptr, variant_col->size()); - casted_variant_columns.push_back(casted_variant); + cast_variant = variant_wrapper(variant, result_type, nullptr, variant_col->size()); + cast_variant_columns.push_back(cast_variant); } /// Second, collect all variants stored in shared variant and cast them to result type. @@ -4534,8 +4534,8 @@ private: } /// Cast all extracted variants into result type. - std::vector casted_shared_variant_columns; - casted_shared_variant_columns.reserve(variant_types_from_shared_variant.size()); + std::vector cast_shared_variant_columns; + cast_shared_variant_columns.reserve(variant_types_from_shared_variant.size()); for (size_t i = 0; i != variant_types_from_shared_variant.size(); ++i) { ColumnsWithTypeAndName variant = {{variant_columns_from_shared_variant[i]->getPtr(), variant_types_from_shared_variant[i], ""}}; @@ -4546,14 +4546,14 @@ private: else variant_wrapper = prepareUnpackDictionaries(variant_types_from_shared_variant[i], result_type); - ColumnPtr casted_variant; + ColumnPtr cast_variant; /// Check if we have wrapper for this variant. if (variant_wrapper) - casted_variant = variant_wrapper(variant, result_type, nullptr, variant_columns_from_shared_variant[i]->size()); - casted_shared_variant_columns.push_back(casted_variant); + cast_variant = variant_wrapper(variant, result_type, nullptr, variant_columns_from_shared_variant[i]->size()); + cast_shared_variant_columns.push_back(cast_variant); } - /// Construct result column from all casted variants. + /// Construct result column from all cast variants. auto res = result_type->createColumn(); res->reserve(input_rows_count); for (size_t i = 0; i != input_rows_count; ++i) @@ -4565,15 +4565,15 @@ private: } else if (global_discr == shared_variant_discr) { - if (casted_shared_variant_columns[shared_variant_indexes[i]]) - res->insertFrom(*casted_shared_variant_columns[shared_variant_indexes[i]], shared_variant_offsets[i]); + if (cast_shared_variant_columns[shared_variant_indexes[i]]) + res->insertFrom(*cast_shared_variant_columns[shared_variant_indexes[i]], shared_variant_offsets[i]); else res->insertDefault(); } else { - if (casted_variant_columns[global_discr]) - res->insertFrom(*casted_variant_columns[global_discr], offsets[i]); + if (cast_variant_columns[global_discr]) + res->insertFrom(*cast_variant_columns[global_discr], offsets[i]); else res->insertDefault(); } @@ -5034,7 +5034,7 @@ private: ColumnPtr converted_column; ColumnPtr res_indexes; - /// For some types default can't be casted (for example, String to Int). In that case convert column to full. + /// For some types default can't be cast (for example, String to Int). In that case convert column to full. bool src_converted_to_full_column = false; { diff --git a/src/Functions/FunctionsExternalDictionaries.h b/src/Functions/FunctionsExternalDictionaries.h index 4c7e1534ba5..d7b51517225 100644 --- a/src/Functions/FunctionsExternalDictionaries.h +++ b/src/Functions/FunctionsExternalDictionaries.h @@ -622,11 +622,11 @@ private: column_before_cast.type, column_before_cast.name}; - auto casted = IColumn::mutate(castColumnAccurate(column_to_cast, result_type)); + auto cast = IColumn::mutate(castColumnAccurate(column_to_cast, result_type)); auto mask_col = ColumnUInt8::create(); mask_col->getData() = std::move(default_mask); - return {std::move(casted), std::move(mask_col)}; + return {std::move(cast), std::move(mask_col)}; } void restoreShortCircuitColumn( @@ -1124,9 +1124,9 @@ private: const auto & hierarchical_attribute = FunctionDictHelper::getDictionaryHierarchicalAttribute(dictionary); auto key_column = ColumnWithTypeAndName{arguments[1].column, arguments[1].type, arguments[1].name}; - auto key_column_casted = castColumnAccurate(key_column, removeNullable(hierarchical_attribute.type)); + auto key_column_cast = castColumnAccurate(key_column, removeNullable(hierarchical_attribute.type)); - ColumnPtr result = dictionary->getHierarchy(key_column_casted, hierarchical_attribute.type); + ColumnPtr result = dictionary->getHierarchy(key_column_cast, hierarchical_attribute.type); return result; } @@ -1182,10 +1182,10 @@ private: auto in_key_column = ColumnWithTypeAndName{arguments[2].column->convertToFullColumnIfConst(), arguments[2].type, arguments[2].name}; auto hierarchical_attribute_non_nullable = removeNullable(hierarchical_attribute.type); - auto key_column_casted = castColumnAccurate(key_column, hierarchical_attribute_non_nullable); - auto in_key_column_casted = castColumnAccurate(in_key_column, hierarchical_attribute_non_nullable); + auto key_column_cast = castColumnAccurate(key_column, hierarchical_attribute_non_nullable); + auto in_key_column_cast = castColumnAccurate(in_key_column, hierarchical_attribute_non_nullable); - ColumnPtr result = dictionary->isInHierarchy(key_column_casted, in_key_column_casted, hierarchical_attribute.type); + ColumnPtr result = dictionary->isInHierarchy(key_column_cast, in_key_column_cast, hierarchical_attribute.type); return result; } @@ -1222,9 +1222,9 @@ public: const auto & hierarchical_attribute = dictionary_helper->getDictionaryHierarchicalAttribute(dictionary); auto key_column = ColumnWithTypeAndName{arguments[1].column->convertToFullColumnIfConst(), arguments[1].type, arguments[1].name}; - auto key_column_casted = castColumnAccurate(key_column, removeNullable(hierarchical_attribute.type)); + auto key_column_cast = castColumnAccurate(key_column, removeNullable(hierarchical_attribute.type)); - return dictionary->getDescendants(key_column_casted, removeNullable(hierarchical_attribute.type), level, hierarchical_parent_to_child_index); + return dictionary->getDescendants(key_column_cast, removeNullable(hierarchical_attribute.type), level, hierarchical_parent_to_child_index); } String name; diff --git a/src/Functions/array/arrayIntersect.cpp b/src/Functions/array/arrayIntersect.cpp index 64bf75bfd50..9df1c1e76fc 100644 --- a/src/Functions/array/arrayIntersect.cpp +++ b/src/Functions/array/arrayIntersect.cpp @@ -100,7 +100,7 @@ private: struct CastArgumentsResult { ColumnsWithTypeAndName initial; - ColumnsWithTypeAndName casted; + ColumnsWithTypeAndName cast; }; static CastArgumentsResult castColumns(const ColumnsWithTypeAndName & arguments, @@ -214,8 +214,8 @@ ColumnPtr FunctionArrayIntersect::castRemoveNullable(const ColumnPtr & col const auto & nested = column_nullable->getNestedColumnPtr(); if (nullable_type) { - auto casted_column = castRemoveNullable(nested, nullable_type->getNestedType()); - return ColumnNullable::create(casted_column, column_nullable->getNullMapColumnPtr()); + auto cast_column = castRemoveNullable(nested, nullable_type->getNestedType()); + return ColumnNullable::create(cast_column, column_nullable->getNullMapColumnPtr()); } return castRemoveNullable(nested, data_type); } @@ -229,8 +229,8 @@ ColumnPtr FunctionArrayIntersect::castRemoveNullable(const ColumnPtr & col data_type->getName(), getName()); - auto casted_column = castRemoveNullable(column_array->getDataPtr(), array_type->getNestedType()); - return ColumnArray::create(casted_column, column_array->getOffsetsPtr()); + auto cast_column = castRemoveNullable(column_array->getDataPtr(), array_type->getNestedType()); + return ColumnArray::create(cast_column, column_array->getOffsetsPtr()); } if (const auto * column_tuple = checkAndGetColumn(column.get())) { @@ -261,7 +261,7 @@ FunctionArrayIntersect::CastArgumentsResult FunctionArrayIntersect:: { size_t num_args = arguments.size(); ColumnsWithTypeAndName initial_columns(num_args); - ColumnsWithTypeAndName casted_columns(num_args); + ColumnsWithTypeAndName cast_columns(num_args); const auto * type_array = checkAndGetDataType(return_type.get()); const auto & type_nested = type_array->getNestedType(); @@ -288,8 +288,8 @@ FunctionArrayIntersect::CastArgumentsResult FunctionArrayIntersect:: { const ColumnWithTypeAndName & arg = arguments[i]; initial_columns[i] = arg; - casted_columns[i] = arg; - auto & column = casted_columns[i]; + cast_columns[i] = arg; + auto & column = cast_columns[i]; if (is_numeric_or_string) { @@ -332,7 +332,7 @@ FunctionArrayIntersect::CastArgumentsResult FunctionArrayIntersect:: } } - return {.initial = initial_columns, .casted = casted_columns}; + return {.initial = initial_columns, .cast = cast_columns}; } static ColumnPtr callFunctionNotEquals(ColumnWithTypeAndName first, ColumnWithTypeAndName second, ContextPtr context) @@ -385,7 +385,7 @@ FunctionArrayIntersect::UnpackedArrays FunctionArrayIntersect::prepa initial_column = &typeid_cast(*initial_column).getNestedColumn(); } - /// In case the column was casted, we need to create an overflow mask for integer types. + /// In case the column was cast, we need to create an overflow mask for integer types. if (arg.nested_column != initial_column) { const auto & nested_init_type = typeid_cast(*removeNullable(initial_columns[i].type)).getNestedType(); @@ -396,7 +396,7 @@ FunctionArrayIntersect::UnpackedArrays FunctionArrayIntersect::prepa || isDateTime(nested_init_type) || isDateTime64(nested_init_type)) { - /// Compare original and casted columns. It seem to be the easiest way. + /// Compare original and cast columns. It seem to be the easiest way. auto overflow_mask = callFunctionNotEquals( {arg.nested_column->getPtr(), nested_init_type, ""}, {initial_column->getPtr(), nested_cast_type, ""}, @@ -458,9 +458,9 @@ ColumnPtr FunctionArrayIntersect::executeImpl(const ColumnsWithTypeAndName else return_type_with_nulls = getLeastSupertype(data_types); - auto casted_columns = castColumns(arguments, result_type, return_type_with_nulls); + auto cast_columns = castColumns(arguments, result_type, return_type_with_nulls); - UnpackedArrays arrays = prepareArrays(casted_columns.casted, casted_columns.initial); + UnpackedArrays arrays = prepareArrays(cast_columns.cast, cast_columns.initial); ColumnPtr result_column; auto not_nullable_nested_return_type = removeNullable(nested_return_type); diff --git a/src/Functions/array/arrayShiftRotate.cpp b/src/Functions/array/arrayShiftRotate.cpp index cea2917af37..59c702376d0 100644 --- a/src/Functions/array/arrayShiftRotate.cpp +++ b/src/Functions/array/arrayShiftRotate.cpp @@ -336,7 +336,7 @@ The default value must be of the same type as the array elements. [example:simple_int_with_default] [example:simple_string_with_default] [example:simple_array_with_default] -[example:casted_array_with_default] +[example:cast_array_with_default] )", .examples{ {"simple_int", "SELECT arrayShiftLeft([1, 2, 3, 4, 5], 3)", "[4, 5, 0, 0, 0]"}, @@ -348,7 +348,7 @@ The default value must be of the same type as the array elements. {"simple_int_with_default", "SELECT arrayShiftLeft([1, 2, 3, 4, 5], 3, 7)", "[4, 5, 7, 7, 7]"}, {"simple_string_with_default", "SELECT arrayShiftLeft(['a', 'b', 'c', 'd', 'e'], 3, 'foo')", "['d', 'e', 'foo', 'foo', 'foo']"}, {"simple_array_with_default", "SELECT arrayShiftLeft([[1, 2], [3, 4], [5, 6]], 2, [7, 8])", "[[5, 6], [7, 8], [7, 8]]"}, - {"casted_array_with_default", + {"cast_array_with_default", "SELECT arrayShiftLeft(CAST('[1, 2, 3, 4, 5, 6]', 'Array(UInt16)'), 1, 1000)", "[2, 3, 4, 5, 6, 1000]"}, }, @@ -374,7 +374,7 @@ The default value must be of the same type as the array elements. [example:simple_int_with_default] [example:simple_string_with_default] [example:simple_array_with_default] -[example:casted_array_with_default] +[example:cast_array_with_default] )", .examples{ {"simple_int", "SELECT arrayShiftRight([1, 2, 3, 4, 5], 3)", "[0, 0, 0, 1, 2]"}, @@ -388,7 +388,7 @@ The default value must be of the same type as the array elements. "SELECT arrayShiftRight(['a', 'b', 'c', 'd', 'e'], 3, 'foo')", "['foo', 'foo', 'foo', 'a', 'b']"}, {"simple_array_with_default", "SELECT arrayShiftRight([[1, 2], [3, 4], [5, 6]], 2, [7, 8])", "[[7, 8], [7, 8], [1, 2]]"}, - {"casted_array_with_default", + {"cast_array_with_default", "SELECT arrayShiftRight(CAST('[1, 2, 3, 4, 5, 6]', 'Array(UInt16)'), 1, 1000)", "[1000, 1, 2, 3, 4, 5]"}, }, diff --git a/src/Functions/neighbor.cpp b/src/Functions/neighbor.cpp index da9192dffce..235e2cced92 100644 --- a/src/Functions/neighbor.cpp +++ b/src/Functions/neighbor.cpp @@ -108,29 +108,29 @@ public: const ColumnWithTypeAndName & offset_elem = arguments[1]; bool has_defaults = arguments.size() == 3; - ColumnPtr source_column_casted = castColumn(source_elem, result_type); + ColumnPtr source_column_cast = castColumn(source_elem, result_type); ColumnPtr offset_column = offset_elem.column; - ColumnPtr default_column_casted; + ColumnPtr default_column_cast; if (has_defaults) { const ColumnWithTypeAndName & default_elem = arguments[2]; - default_column_casted = castColumn(default_elem, result_type); + default_column_cast = castColumn(default_elem, result_type); } - bool source_is_constant = isColumnConst(*source_column_casted); + bool source_is_constant = isColumnConst(*source_column_cast); bool offset_is_constant = isColumnConst(*offset_column); bool default_is_constant = false; if (has_defaults) - default_is_constant = isColumnConst(*default_column_casted); + default_is_constant = isColumnConst(*default_column_cast); if (source_is_constant) - source_column_casted = assert_cast(*source_column_casted).getDataColumnPtr(); + source_column_cast = assert_cast(*source_column_cast).getDataColumnPtr(); if (offset_is_constant) offset_column = assert_cast(*offset_column).getDataColumnPtr(); if (default_is_constant) - default_column_casted = assert_cast(*default_column_casted).getDataColumnPtr(); + default_column_cast = assert_cast(*default_column_cast).getDataColumnPtr(); if (offset_is_constant) { @@ -177,18 +177,18 @@ public: { /// Degenerate case, just copy source column as is. return source_is_constant - ? ColumnConst::create(source_column_casted, input_rows_count) - : source_column_casted; + ? ColumnConst::create(source_column_cast, input_rows_count) + : source_column_cast; } if (offset > 0) { - insert_range_from(source_is_constant, source_column_casted, offset, static_cast(input_rows_count) - offset); - insert_range_from(default_is_constant, default_column_casted, static_cast(input_rows_count) - offset, offset); + insert_range_from(source_is_constant, source_column_cast, offset, static_cast(input_rows_count) - offset); + insert_range_from(default_is_constant, default_column_cast, static_cast(input_rows_count) - offset, offset); return result_column; } - insert_range_from(default_is_constant, default_column_casted, 0, -offset); - insert_range_from(source_is_constant, source_column_casted, 0, static_cast(input_rows_count) + offset); + insert_range_from(default_is_constant, default_column_cast, 0, -offset); + insert_range_from(source_is_constant, source_column_cast, 0, static_cast(input_rows_count) + offset); return result_column; } @@ -205,9 +205,9 @@ public: Int64 src_idx = row + offset; if (src_idx >= 0 && src_idx < static_cast(input_rows_count)) - result_column->insertFrom(*source_column_casted, source_is_constant ? 0 : src_idx); + result_column->insertFrom(*source_column_cast, source_is_constant ? 0 : src_idx); else if (has_defaults) - result_column->insertFrom(*default_column_casted, default_is_constant ? 0 : row); + result_column->insertFrom(*default_column_cast, default_is_constant ? 0 : row); else result_column->insertDefault(); } diff --git a/src/Functions/parseDateTime.cpp b/src/Functions/parseDateTime.cpp index 362a1c30288..f7d37c27f85 100644 --- a/src/Functions/parseDateTime.cpp +++ b/src/Functions/parseDateTime.cpp @@ -678,8 +678,8 @@ namespace } else { - const auto * result_type_without_nullable_casted = checkAndGetDataType(result_type_without_nullable.get()); - MutableColumnPtr col_res = ColumnDateTime64::create(input_rows_count, result_type_without_nullable_casted->getScale()); + const auto * result_type_without_nullable_cast = checkAndGetDataType(result_type_without_nullable.get()); + MutableColumnPtr col_res = ColumnDateTime64::create(input_rows_count, result_type_without_nullable_cast->getScale()); ColumnDateTime64 * col_datetime64 = assert_cast(col_res.get()); return executeImpl2(arguments, result_type, input_rows_count, col_res, col_datetime64->getData()); } @@ -701,8 +701,8 @@ namespace UInt32 scale = 0; if constexpr (return_type == ReturnType::DateTime64) { - const DataTypeDateTime64 * result_type_without_nullable_casted = checkAndGetDataType(removeNullable(result_type).get()); - scale = result_type_without_nullable_casted->getScale(); + const DataTypeDateTime64 * result_type_without_nullable_cast = checkAndGetDataType(removeNullable(result_type).get()); + scale = result_type_without_nullable_cast->getScale(); multiplier = DecimalUtils::scaleMultiplier(scale); } diff --git a/src/Functions/transform.cpp b/src/Functions/transform.cpp index e5445b36809..6cda47a1cc8 100644 --- a/src/Functions/transform.cpp +++ b/src/Functions/transform.cpp @@ -158,9 +158,9 @@ namespace } } - ColumnPtr in_casted = arguments[0].column; + ColumnPtr in_cast = arguments[0].column; if (arguments.size() == 3) - in_casted = castColumn(arguments[0], result_type); + in_cast = castColumn(arguments[0], result_type); auto column_result = result_type->createColumn(); if (cache.is_empty) @@ -171,18 +171,18 @@ namespace } if (cache.table_num_to_idx) { - if (!executeNum>(in, *column_result, default_non_const, *in_casted, input_rows_count) - && !executeNum>(in, *column_result, default_non_const, *in_casted, input_rows_count) - && !executeNum>(in, *column_result, default_non_const, *in_casted, input_rows_count) - && !executeNum>(in, *column_result, default_non_const, *in_casted, input_rows_count) - && !executeNum>(in, *column_result, default_non_const, *in_casted, input_rows_count) - && !executeNum>(in, *column_result, default_non_const, *in_casted, input_rows_count) - && !executeNum>(in, *column_result, default_non_const, *in_casted, input_rows_count) - && !executeNum>(in, *column_result, default_non_const, *in_casted, input_rows_count) - && !executeNum>(in, *column_result, default_non_const, *in_casted, input_rows_count) - && !executeNum>(in, *column_result, default_non_const, *in_casted, input_rows_count) - && !executeNum>(in, *column_result, default_non_const, *in_casted, input_rows_count) - && !executeNum>(in, *column_result, default_non_const, *in_casted, input_rows_count)) + if (!executeNum>(in, *column_result, default_non_const, *in_cast, input_rows_count) + && !executeNum>(in, *column_result, default_non_const, *in_cast, input_rows_count) + && !executeNum>(in, *column_result, default_non_const, *in_cast, input_rows_count) + && !executeNum>(in, *column_result, default_non_const, *in_cast, input_rows_count) + && !executeNum>(in, *column_result, default_non_const, *in_cast, input_rows_count) + && !executeNum>(in, *column_result, default_non_const, *in_cast, input_rows_count) + && !executeNum>(in, *column_result, default_non_const, *in_cast, input_rows_count) + && !executeNum>(in, *column_result, default_non_const, *in_cast, input_rows_count) + && !executeNum>(in, *column_result, default_non_const, *in_cast, input_rows_count) + && !executeNum>(in, *column_result, default_non_const, *in_cast, input_rows_count) + && !executeNum>(in, *column_result, default_non_const, *in_cast, input_rows_count) + && !executeNum>(in, *column_result, default_non_const, *in_cast, input_rows_count)) { throw Exception( ErrorCodes::ILLEGAL_COLUMN, "Illegal column {} of first argument of function {}", in->getName(), getName()); @@ -190,12 +190,12 @@ namespace } else if (cache.table_string_to_idx) { - if (!executeString(in, *column_result, default_non_const, *in_casted, input_rows_count)) - executeContiguous(in, *column_result, default_non_const, *in_casted, input_rows_count); + if (!executeString(in, *column_result, default_non_const, *in_cast, input_rows_count)) + executeContiguous(in, *column_result, default_non_const, *in_cast, input_rows_count); } else if (cache.table_anything_to_idx) { - executeAnything(in, *column_result, default_non_const, *in_casted, input_rows_count); + executeAnything(in, *column_result, default_non_const, *in_cast, input_rows_count); } else throw Exception(ErrorCodes::LOGICAL_ERROR, "State of the function `transform` is not initialized"); @@ -216,7 +216,7 @@ namespace return impl->execute(args, result_type, input_rows_count); } - void executeAnything(const IColumn * in, IColumn & column_result, const ColumnPtr default_non_const, const IColumn & in_casted, size_t input_rows_count) const + void executeAnything(const IColumn * in, IColumn & column_result, const ColumnPtr default_non_const, const IColumn & in_cast, size_t input_rows_count) const { const auto & table = *cache.table_anything_to_idx; column_result.reserve(input_rows_count); @@ -233,11 +233,11 @@ namespace else if (default_non_const) column_result.insertFrom(*default_non_const, i); else - column_result.insertFrom(in_casted, i); + column_result.insertFrom(in_cast, i); } } - void executeContiguous(const IColumn * in, IColumn & column_result, const ColumnPtr default_non_const, const IColumn & in_casted, size_t input_rows_count) const + void executeContiguous(const IColumn * in, IColumn & column_result, const ColumnPtr default_non_const, const IColumn & in_cast, size_t input_rows_count) const { const auto & table = *cache.table_string_to_idx; column_result.reserve(input_rows_count); @@ -251,12 +251,12 @@ namespace else if (default_non_const) column_result.insertFrom(*default_non_const, i); else - column_result.insertFrom(in_casted, i); + column_result.insertFrom(in_cast, i); } } template - bool executeNum(const IColumn * in_untyped, IColumn & column_result, const ColumnPtr default_non_const, const IColumn & in_casted, size_t input_rows_count) const + bool executeNum(const IColumn * in_untyped, IColumn & column_result, const ColumnPtr default_non_const, const IColumn & in_cast, size_t input_rows_count) const { const auto * const in = checkAndGetColumn(in_untyped); if (!in) @@ -292,7 +292,7 @@ namespace else if (default_non_const) column_result.insertFrom(*default_non_const, i); else - column_result.insertFrom(in_casted, i); + column_result.insertFrom(in_cast, i); } } return true; @@ -444,7 +444,7 @@ namespace } } - bool executeString(const IColumn * in_untyped, IColumn & column_result, const ColumnPtr default_non_const, const IColumn & in_casted, size_t input_rows_count) const + bool executeString(const IColumn * in_untyped, IColumn & column_result, const ColumnPtr default_non_const, const IColumn & in_cast, size_t input_rows_count) const { const auto * const in = checkAndGetColumn(in_untyped); if (!in) @@ -481,7 +481,7 @@ namespace else if (default_non_const) column_result.insertFrom(*default_non_const, i); else - column_result.insertFrom(in_casted, i); + column_result.insertFrom(in_cast, i); } } return true; @@ -699,11 +699,11 @@ namespace throw Exception( ErrorCodes::ILLEGAL_COLUMN, "Second and third arguments of function {} must be constant arrays.", getName()); - const ColumnPtr & from_column_uncasted = array_from->getDataPtr(); + const ColumnPtr & from_column_uncast = array_from->getDataPtr(); cache.from_column = castColumn( { - from_column_uncasted, + from_column_uncast, typeid_cast(*arguments[1].type).getNestedType(), arguments[1].name }, @@ -756,7 +756,7 @@ namespace for (size_t i = 0; i < size; ++i) { if (which.isEnum() /// The correctness of strings are already checked by casting them to the Enum type. - || applyVisitor(FieldVisitorAccurateEquals(), (*cache.from_column)[i], (*from_column_uncasted)[i])) + || applyVisitor(FieldVisitorAccurateEquals(), (*cache.from_column)[i], (*from_column_uncast)[i])) { UInt64 key = 0; auto * dst = reinterpret_cast(&key); @@ -779,7 +779,7 @@ namespace auto & table = *cache.table_string_to_idx; for (size_t i = 0; i < size; ++i) { - if (applyVisitor(FieldVisitorAccurateEquals(), (*cache.from_column)[i], (*from_column_uncasted)[i])) + if (applyVisitor(FieldVisitorAccurateEquals(), (*cache.from_column)[i], (*from_column_uncast)[i])) { StringRef ref = cache.from_column->getDataAt(i); table.insertIfNotPresent(ref, i); @@ -792,7 +792,7 @@ namespace auto & table = *cache.table_anything_to_idx; for (size_t i = 0; i < size; ++i) { - if (applyVisitor(FieldVisitorAccurateEquals(), (*cache.from_column)[i], (*from_column_uncasted)[i])) + if (applyVisitor(FieldVisitorAccurateEquals(), (*cache.from_column)[i], (*from_column_uncast)[i])) { SipHash hash; cache.from_column->updateHashWithValue(i, hash); diff --git a/src/Functions/widthBucket.cpp b/src/Functions/widthBucket.cpp index 55b6b27df1e..45f8553d7e7 100644 --- a/src/Functions/widthBucket.cpp +++ b/src/Functions/widthBucket.cpp @@ -130,21 +130,21 @@ class FunctionWidthBucket : public IFunction using ResultType = typename NumberTraits::Construct::Type; auto common_type = std::make_shared>(); - std::vector casted_columns; - casted_columns.reserve(3); + std::vector cast_columns; + cast_columns.reserve(3); for (const auto argument_index : collections::range(0, 3)) { - casted_columns.push_back(castColumn(arguments[argument_index], common_type)); + cast_columns.push_back(castColumn(arguments[argument_index], common_type)); } - const auto * operands_vec = getDataIfNotNull(checkAndGetColumn>(casted_columns[0].get())); - const auto * lows_vec = getDataIfNotNull(checkAndGetColumn>(casted_columns[1].get())); - const auto * highs_vec = getDataIfNotNull(checkAndGetColumn>(casted_columns[2].get())); + const auto * operands_vec = getDataIfNotNull(checkAndGetColumn>(cast_columns[0].get())); + const auto * lows_vec = getDataIfNotNull(checkAndGetColumn>(cast_columns[1].get())); + const auto * highs_vec = getDataIfNotNull(checkAndGetColumn>(cast_columns[2].get())); const auto * counts_vec = getDataIfNotNull(checkAndGetColumn>(arguments[3].column.get())); - const auto * operands_col_const = checkAndGetColumnConst>(casted_columns[0].get()); - const auto * lows_col_const = checkAndGetColumnConst>(casted_columns[1].get()); - const auto * highs_col_const = checkAndGetColumnConst>(casted_columns[2].get()); + const auto * operands_col_const = checkAndGetColumnConst>(cast_columns[0].get()); + const auto * lows_col_const = checkAndGetColumnConst>(cast_columns[1].get()); + const auto * highs_col_const = checkAndGetColumnConst>(cast_columns[2].get()); const auto * counts_col_const = checkAndGetColumnConst>(arguments[3].column.get()); throwIfInvalid(0, operands_col_const, operands_vec, input_rows_count); diff --git a/src/Interpreters/ActionsDAG.cpp b/src/Interpreters/ActionsDAG.cpp index e536ca9c0c6..d9b646c032d 100644 --- a/src/Interpreters/ActionsDAG.cpp +++ b/src/Interpreters/ActionsDAG.cpp @@ -1459,7 +1459,7 @@ ActionsDAG ActionsDAG::makeConvertingActions( const ColumnsWithTypeAndName & result, MatchColumnsMode mode, bool ignore_constant_values, - bool add_casted_columns, + bool add_cast_columns, NameToNameMap * new_names) { size_t num_input_columns = source.size(); @@ -1468,8 +1468,8 @@ ActionsDAG ActionsDAG::makeConvertingActions( if (mode == MatchColumnsMode::Position && num_input_columns != num_result_columns) throw Exception(ErrorCodes::NUMBER_OF_COLUMNS_DOESNT_MATCH, "Number of columns doesn't match (source: {} and result: {})", num_input_columns, num_result_columns); - if (add_casted_columns && mode != MatchColumnsMode::Name) - throw Exception(ErrorCodes::LOGICAL_ERROR, "Converting with add_casted_columns supported only for MatchColumnsMode::Name"); + if (add_cast_columns && mode != MatchColumnsMode::Name) + throw Exception(ErrorCodes::LOGICAL_ERROR, "Converting with add_cast_columns supported only for MatchColumnsMode::Name"); ActionsDAG actions_dag(source); NodeRawConstPtrs projection(num_result_columns); @@ -1567,7 +1567,7 @@ ActionsDAG ActionsDAG::makeConvertingActions( if (dst_node->result_name != res_elem.name) { - if (add_casted_columns) + if (add_cast_columns) { if (inputs.contains(dst_node->result_name)) throw Exception(ErrorCodes::ILLEGAL_COLUMN, "Cannot convert column `{}` to `{}` because other column have same name", diff --git a/src/Interpreters/ActionsDAG.h b/src/Interpreters/ActionsDAG.h index ac92d99bfa8..2811be42b4e 100644 --- a/src/Interpreters/ActionsDAG.h +++ b/src/Interpreters/ActionsDAG.h @@ -298,14 +298,14 @@ public: /// It is needed to convert result from different sources to the same structure, e.g. for UNION query. /// Conversion should be possible with only usage of CAST function and renames. /// @param ignore_constant_values - Do not check that constants are same. Use value from result_header. - /// @param add_casted_columns - Create new columns with converted values instead of replacing original. - /// @param new_names - Output parameter for new column names when add_casted_columns is used. + /// @param add_cast_columns - Create new columns with converted values instead of replacing original. + /// @param new_names - Output parameter for new column names when add_cast_columns is used. static ActionsDAG makeConvertingActions( const ColumnsWithTypeAndName & source, const ColumnsWithTypeAndName & result, MatchColumnsMode mode, bool ignore_constant_values = false, - bool add_casted_columns = false, + bool add_cast_columns = false, NameToNameMap * new_names = nullptr); /// Create expression which add const column and then materialize it. diff --git a/src/Interpreters/AddDefaultDatabaseVisitor.h b/src/Interpreters/AddDefaultDatabaseVisitor.h index 4aebccbc6dd..57c2c092188 100644 --- a/src/Interpreters/AddDefaultDatabaseVisitor.h +++ b/src/Interpreters/AddDefaultDatabaseVisitor.h @@ -26,7 +26,7 @@ namespace DB { -/// Visitors consist of functions with unified interface 'void visit(Casted & x, ASTPtr & y)', there x is y, successfully casted to Casted. +/// Visitors consist of functions with unified interface 'void visit(Cast & x, ASTPtr & y)', there x is y, successfully cast to Cast. /// Both types and function could have const specifiers. The second argument is used by visitor to replaces AST node (y) if needed. /// Visits AST nodes, add default database to tables if not set. There's different logic for DDLs and selects. diff --git a/src/Interpreters/TableJoin.cpp b/src/Interpreters/TableJoin.cpp index 2532dddba3c..e39fdff93e0 100644 --- a/src/Interpreters/TableJoin.cpp +++ b/src/Interpreters/TableJoin.cpp @@ -744,7 +744,7 @@ static std::optional changeKeyTypes(const ColumnsWithTypeAndName & c /* result= */ cols_dst, /* mode= */ ActionsDAG::MatchColumnsMode::Name, /* ignore_constant_values= */ true, - /* add_casted_columns= */ add_new_cols, + /* add_cast_columns= */ add_new_cols, /* new_names= */ &key_column_rename); } @@ -771,7 +771,7 @@ static std::optional changeTypesToNullable( /* result= */ cols_dst, /* mode= */ ActionsDAG::MatchColumnsMode::Name, /* ignore_constant_values= */ true, - /* add_casted_columns= */ false, + /* add_cast_columns= */ false, /* new_names= */ nullptr); } diff --git a/src/Interpreters/evaluateConstantExpression.cpp b/src/Interpreters/evaluateConstantExpression.cpp index 677e0d7b2ec..e2009cb44d4 100644 --- a/src/Interpreters/evaluateConstantExpression.cpp +++ b/src/Interpreters/evaluateConstantExpression.cpp @@ -597,15 +597,15 @@ namespace if (column->size() > max_elements) return {}; - ColumnPtr casted_col; + ColumnPtr cast_col; const NullMap * null_map = nullptr; if (!type->equals(*node->result_type)) { - casted_col = tryCastColumn(column, value->result_type, node->result_type); - if (!casted_col) + cast_col = tryCastColumn(column, value->result_type, node->result_type); + if (!cast_col) return {}; - const auto & col_nullable = assert_cast(*casted_col); + const auto & col_nullable = assert_cast(*cast_col); null_map = &col_nullable.getNullMapData(); column = col_nullable.getNestedColumnPtr(); } diff --git a/src/Interpreters/getColumnFromBlock.cpp b/src/Interpreters/getColumnFromBlock.cpp index 89166bb2b3e..799e11ddaa7 100644 --- a/src/Interpreters/getColumnFromBlock.cpp +++ b/src/Interpreters/getColumnFromBlock.cpp @@ -42,8 +42,8 @@ ColumnPtr tryGetSubcolumnFromBlock(const Block & block, const DataTypePtr & requ /// extract the subcolumn, because the data of dynamic subcolumn can change after cast. if ((elem->type->hasDynamicSubcolumns() || requested_column_type->hasDynamicSubcolumns()) && !elem->type->equals(*requested_column_type)) { - auto casted_column = castColumn({elem->column, elem->type, ""}, requested_column_type); - auto elem_column = requested_column_type->tryGetSubcolumn(subcolumn_name, casted_column); + auto cast_column = castColumn({elem->column, elem->type, ""}, requested_column_type); + auto elem_column = requested_column_type->tryGetSubcolumn(subcolumn_name, cast_column); auto elem_type = requested_column_type->tryGetSubcolumnType(subcolumn_name); if (!elem_type || !elem_column) diff --git a/src/Loggers/OwnSplitChannel.h b/src/Loggers/OwnSplitChannel.h index 88bb6b9ce76..d292191ee12 100644 --- a/src/Loggers/OwnSplitChannel.h +++ b/src/Loggers/OwnSplitChannel.h @@ -44,7 +44,7 @@ private: void tryLogSplit(const Poco::Message & msg); using ChannelPtr = Poco::AutoPtr; - /// Handler and its pointer casted to extended interface + /// Handler and its pointer cast to extended interface using ExtendedChannelPtrPair = std::pair; std::map channels; diff --git a/src/Parsers/IAST.h b/src/Parsers/IAST.h index eb6ddcc5d8b..07b32c7d8e2 100644 --- a/src/Parsers/IAST.h +++ b/src/Parsers/IAST.h @@ -120,12 +120,12 @@ public: if (!child) return; - T * casted = dynamic_cast(child.get()); - if (!casted) + T * cast = dynamic_cast(child.get()); + if (!cast) throw Exception(ErrorCodes::LOGICAL_ERROR, "Could not cast AST subtree"); children.push_back(child); - field = casted; + field = cast; } template @@ -134,8 +134,8 @@ public: if (!child) throw Exception(ErrorCodes::LOGICAL_ERROR, "Trying to replace AST subtree with nullptr"); - T * casted = dynamic_cast(child.get()); - if (!casted) + T * cast = dynamic_cast(child.get()); + if (!cast) throw Exception(ErrorCodes::LOGICAL_ERROR, "Could not cast AST subtree"); for (ASTPtr & current_child : children) @@ -143,7 +143,7 @@ public: if (current_child.get() == field) { current_child = child; - field = casted; + field = cast; return; } } diff --git a/src/Processors/Transforms/WindowTransform.cpp b/src/Processors/Transforms/WindowTransform.cpp index 597a6861eeb..00d13c64036 100644 --- a/src/Processors/Transforms/WindowTransform.cpp +++ b/src/Processors/Transforms/WindowTransform.cpp @@ -1153,7 +1153,7 @@ void WindowTransform::appendChunk(Chunk & chunk) // Initialize output columns. for (auto & ws : workspaces) { - block.casted_columns.push_back(ws.window_function_impl ? ws.window_function_impl->castColumn(block.input_columns, ws.argument_column_indices) : nullptr); + block.cast_columns.push_back(ws.window_function_impl ? ws.window_function_impl->castColumn(block.input_columns, ws.argument_column_indices) : nullptr); block.output_columns.push_back(ws.aggregate_function->getResultType() ->createColumn()); @@ -2401,8 +2401,8 @@ struct WindowFunctionLagLeadInFrame final : public StatelessWindowFunction { // Column with default values is specified. const IColumn & default_column = - current_block.casted_columns[function_index] ? - *current_block.casted_columns[function_index].get() : + current_block.cast_columns[function_index] ? + *current_block.cast_columns[function_index].get() : *current_block.input_columns[workspace.argument_column_indices[2]].get(); to.insert(default_column[transform->current_row.row]); diff --git a/src/Processors/Transforms/WindowTransform.h b/src/Processors/Transforms/WindowTransform.h index cb672ad6841..c58735fd45c 100644 --- a/src/Processors/Transforms/WindowTransform.h +++ b/src/Processors/Transforms/WindowTransform.h @@ -27,7 +27,7 @@ struct WindowTransformBlock { Columns original_input_columns; Columns input_columns; - Columns casted_columns; + Columns cast_columns; MutableColumns output_columns; size_t rows = 0; diff --git a/src/Storages/ColumnsDescription.h b/src/Storages/ColumnsDescription.h index 27496da543a..0ffb3bcc01a 100644 --- a/src/Storages/ColumnsDescription.h +++ b/src/Storages/ColumnsDescription.h @@ -279,7 +279,7 @@ struct DefaultExpressionsInfo void getDefaultExpressionInfoInto(const ASTColumnDeclaration & col_decl, const DataTypePtr & data_type, DefaultExpressionsInfo & info); /// Validate default expressions and corresponding types compatibility, i.e. -/// default expression result can be casted to column_type. Also checks, that we +/// default expression result can be cast to column_type. Also checks, that we /// don't have strange constructions in default expression like SELECT query or /// arrayJoin function. void validateColumnsDefaults(ASTPtr default_expr_list, const NamesAndTypesList & all_columns, ContextPtr context); diff --git a/src/Storages/MergeTree/KeyCondition.cpp b/src/Storages/MergeTree/KeyCondition.cpp index 9e19ffe1b04..5e88ffbe3b0 100644 --- a/src/Storages/MergeTree/KeyCondition.cpp +++ b/src/Storages/MergeTree/KeyCondition.cpp @@ -977,13 +977,13 @@ bool applyFunctionChainToColumn( // And cast it to the argument type of the first function in the chain auto in_argument_type = functions[0]->getArgumentTypes()[0]; - if (canBeSafelyCasted(result_type, in_argument_type)) + if (canBeSafelyCast(result_type, in_argument_type)) { result_column = castColumnAccurate({result_column, result_type, ""}, in_argument_type); result_type = in_argument_type; } - // If column cannot be casted accurate, casting with OrNull, and in case all - // values has been casted (no nulls), unpacking nested column from nullable. + // If column cannot be cast accurate, casting with OrNull, and in case all + // values has been cast (no nulls), unpacking nested column from nullable. // In case any further functions require Nullable input, they'll be able // to cast it. else @@ -1006,7 +1006,7 @@ bool applyFunctionChainToColumn( return false; auto argument_type = func->getArgumentTypes()[0]; - if (!canBeSafelyCasted(result_type, argument_type)) + if (!canBeSafelyCast(result_type, argument_type)) return false; result_column = castColumnAccurate({result_column, result_type, ""}, argument_type); @@ -1306,7 +1306,7 @@ bool KeyCondition::tryPrepareSetIndex( is_constant_transformed = true; } - if (canBeSafelyCasted(set_element_type, key_column_type)) + if (canBeSafelyCast(set_element_type, key_column_type)) { transformed_set_columns[set_element_index] = castColumn({set_column, set_element_type, {}}, key_column_type); continue; @@ -2085,7 +2085,7 @@ bool KeyCondition::extractAtomFromTree(const RPNBuilderTreeNode & node, RPNEleme else key_expr_type_not_null = key_expr_type; - bool cast_not_needed = is_set_const /// Set args are already casted inside Set::createFromAST + bool cast_not_needed = is_set_const /// Set args are already cast inside Set::createFromAST || ((isNativeInteger(key_expr_type_not_null) || isDateTime(key_expr_type_not_null)) && (isNativeInteger(const_type) || isDateTime(const_type))); /// Native integers and DateTime are accurately compared without cast. diff --git a/src/Storages/MergeTree/MergeTreeSplitPrewhereIntoReadSteps.cpp b/src/Storages/MergeTree/MergeTreeSplitPrewhereIntoReadSteps.cpp index 1cc4006a285..6bb8ff36a50 100644 --- a/src/Storages/MergeTree/MergeTreeSplitPrewhereIntoReadSteps.cpp +++ b/src/Storages/MergeTree/MergeTreeSplitPrewhereIntoReadSteps.cpp @@ -150,7 +150,7 @@ const ActionsDAG::Node & addFunction( /// Adds a CAST node with the regular name ("CAST(...)") or with the provided name. /// This is different from ActionsDAG::addCast() because it set the name equal to the original name effectively hiding the value before cast, -/// but it might be required for further steps with its original uncasted type. +/// but it might be required for further steps with its original uncast type. const ActionsDAG::Node & addCast( const ActionsDAGPtr & dag, const ActionsDAG::Node & node_to_cast, @@ -246,7 +246,7 @@ bool tryBuildPrewhereSteps( struct Step { ActionsDAGPtr actions; - /// Original condition, in case if we have only one condition, and it was not casted + /// Original condition, in case if we have only one condition, and it was not cast const ActionsDAG::Node * original_node; /// Result condition node const ActionsDAG::Node * result_node; diff --git a/tests/queries/0_stateless/00298_enum_width_and_cast.reference b/tests/queries/0_stateless/00298_enum_width_and_cast.reference index 706e3f2ae98..dde2258b8c7 100644 --- a/tests/queries/0_stateless/00298_enum_width_and_cast.reference +++ b/tests/queries/0_stateless/00298_enum_width_and_cast.reference @@ -10,8 +10,8 @@ 2. │ \ │ 0 │ 3. │ \t │ 0 │ └──────────┴───┘ - ┌─x────────┬─y─┬─toInt8(x)─┬─s─────┬─casted─┐ -1. │ Hello │ 0 │ -100 │ Hello │ Hello │ -2. │ \ │ 0 │ 0 │ \ │ \ │ -3. │ \t │ 0 │ 111 │ \t │ \t │ - └──────────┴───┴───────────┴───────┴────────┘ + ┌─x────────┬─y─┬─toInt8(x)─┬─s─────┬─cast──┐ +1. │ Hello │ 0 │ -100 │ Hello │ Hello │ +2. │ \ │ 0 │ 0 │ \ │ \ │ +3. │ \t │ 0 │ 111 │ \t │ \t │ + └──────────┴───┴───────────┴───────┴─────────┘ diff --git a/tests/queries/0_stateless/00298_enum_width_and_cast.sql b/tests/queries/0_stateless/00298_enum_width_and_cast.sql index 35241f5124d..7d46418dcab 100644 --- a/tests/queries/0_stateless/00298_enum_width_and_cast.sql +++ b/tests/queries/0_stateless/00298_enum_width_and_cast.sql @@ -8,6 +8,6 @@ INSERT INTO enum (x) VALUES ('\\'); SELECT * FROM enum ORDER BY x, y FORMAT PrettyCompact; INSERT INTO enum (x) VALUES ('\t\\t'); SELECT * FROM enum ORDER BY x, y FORMAT PrettyCompact; -SELECT x, y, toInt8(x), toString(x) AS s, CAST(s AS Enum8('Hello' = -100, '\\' = 0, '\t\\t' = 111)) AS casted FROM enum ORDER BY x, y FORMAT PrettyCompact; +SELECT x, y, toInt8(x), toString(x) AS s, CAST(s AS Enum8('Hello' = -100, '\\' = 0, '\t\\t' = 111)) AS cast FROM enum ORDER BY x, y FORMAT PrettyCompact; DROP TABLE enum; diff --git a/tests/queries/0_stateless/01655_plan_optimizations.reference b/tests/queries/0_stateless/01655_plan_optimizations.reference index 7fc7556e85b..fb27e0c3d74 100644 --- a/tests/queries/0_stateless/01655_plan_optimizations.reference +++ b/tests/queries/0_stateless/01655_plan_optimizations.reference @@ -61,12 +61,12 @@ Filter column: notEquals(__table1.y, 0_UInt8) 7 8 8 9 9 10 -> one condition of filter should be pushed down after aggregating, other condition is casted +> one condition of filter should be pushed down after aggregating, other condition is cast Filter column FUNCTION and(minus(s, 4) :: 5, 1 :: 3) -> and(notEquals(y, 0), minus(s, 4)) Aggregating Filter column: notEquals(y, 0) -> (analyzer) one condition of filter should be pushed down after aggregating, other condition is casted +> (analyzer) one condition of filter should be pushed down after aggregating, other condition is cast Filter column FUNCTION and(minus(__table1.s, 4_UInt8) :: 1, 1 :: 3) -> and(notEquals(__table1.y, 0_UInt8), minus(__table1.s, 4_UInt8)) Aggregating diff --git a/tests/queries/0_stateless/01655_plan_optimizations.sh b/tests/queries/0_stateless/01655_plan_optimizations.sh index 04ab9bbd11c..52bfdb91467 100755 --- a/tests/queries/0_stateless/01655_plan_optimizations.sh +++ b/tests/queries/0_stateless/01655_plan_optimizations.sh @@ -63,14 +63,14 @@ $CLICKHOUSE_CLIENT -q " ) where y != 0 and s != 4 order by s, y settings enable_optimize_predicate_expression=0" -echo "> one condition of filter should be pushed down after aggregating, other condition is casted" +echo "> one condition of filter should be pushed down after aggregating, other condition is cast" $CLICKHOUSE_CLIENT --enable_analyzer=0 -q " explain actions = 1 select s, y from ( select sum(x) as s, y from (select number as x, number + 1 as y from numbers(10)) group by y ) where y != 0 and s - 4 settings enable_optimize_predicate_expression=0" | grep -o "Aggregating\|Filter column\|Filter column: notEquals(y, 0)\|FUNCTION and(minus(s, 4) :: 5, 1 :: 3) -> and(notEquals(y, 0), minus(s, 4))" -echo "> (analyzer) one condition of filter should be pushed down after aggregating, other condition is casted" +echo "> (analyzer) one condition of filter should be pushed down after aggregating, other condition is cast" $CLICKHOUSE_CLIENT --enable_analyzer=1 -q " explain actions = 1 select s, y from ( select sum(x) as s, y from (select number as x, number + 1 as y from numbers(10)) group by y diff --git a/utils/check-style/aspell-ignore/en/aspell-dict.txt b/utils/check-style/aspell-ignore/en/aspell-dict.txt index a53104581bb..5edabe2ba3f 100644 --- a/utils/check-style/aspell-ignore/en/aspell-dict.txt +++ b/utils/check-style/aspell-ignore/en/aspell-dict.txt @@ -1380,7 +1380,6 @@ bools boringssl boundingRatio bozerkins -broadcasted brotli bson bsoneachrow @@ -1406,7 +1405,6 @@ cardinalities cardinality cartesian cassandra -casted catboost catboostEvaluate categoricalInformationValue From c7093386da3988022098e2491c599b3c44ed650a Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Mon, 18 Nov 2024 03:42:53 +0100 Subject: [PATCH 2/2] Update test --- tests/queries/0_stateless/00298_enum_width_and_cast.reference | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/queries/0_stateless/00298_enum_width_and_cast.reference b/tests/queries/0_stateless/00298_enum_width_and_cast.reference index dde2258b8c7..b8fb5ebecc1 100644 --- a/tests/queries/0_stateless/00298_enum_width_and_cast.reference +++ b/tests/queries/0_stateless/00298_enum_width_and_cast.reference @@ -13,5 +13,5 @@ ┌─x────────┬─y─┬─toInt8(x)─┬─s─────┬─cast──┐ 1. │ Hello │ 0 │ -100 │ Hello │ Hello │ 2. │ \ │ 0 │ 0 │ \ │ \ │ -3. │ \t │ 0 │ 111 │ \t │ \t │ - └──────────┴───┴───────────┴───────┴─────────┘ +3. │ \t │ 0 │ 111 │ \t │ \t │ + └──────────┴───┴───────────┴───────┴───────┘