Skip to content

Commit

Permalink
Merge pull request #60160 from rschu1ze/bool-cast
Browse files Browse the repository at this point in the history
Allow casting of bools in string representation to to true bools
  • Loading branch information
rschu1ze committed Feb 20, 2024
2 parents f7de95c + df53826 commit a1a45ed
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Interpreters/convertFieldToType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,12 @@ Field convertFieldToTypeImpl(const Field & src, const IDataType & type, const ID
{
/// Promote data type to avoid overflows. Note that overflows in the largest data type are still possible.
/// But don't promote Float32, since we want to keep the exact same value
/// Also don't promote domain types (like bool) because we would otherwise use the serializer of the promoted type (e.g. UInt64 for
/// bool, which does not allow 'true' and 'false' as input values)
const IDataType * type_to_parse = &type;
DataTypePtr holder;

if (type.canBePromoted() && !which_type.isFloat32())
if (type.canBePromoted() && !which_type.isFloat32() && !type.getCustomSerialization())
{
holder = type.promoteNumericType();
type_to_parse = holder.get();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select true = 'true';

0 comments on commit a1a45ed

Please sign in to comment.