Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not promote float32 automatically #58724

Merged
merged 3 commits into from Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Interpreters/convertFieldToType.cpp
Expand Up @@ -492,10 +492,11 @@ Field convertFieldToTypeImpl(const Field & src, const IDataType & type, const ID
if (src.getType() == Field::Types::String)
{
/// 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
const IDataType * type_to_parse = &type;
DataTypePtr holder;

if (type.canBePromoted())
if (type.canBePromoted() && !which_type.isFloat32())
{
holder = type.promoteNumericType();
type_to_parse = holder.get();
Expand Down
@@ -0,0 +1 @@
49.9
6 changes: 6 additions & 0 deletions tests/queries/0_stateless/02966_float32_promotion.sql
@@ -0,0 +1,6 @@
-- https://github.com/ClickHouse/ClickHouse/issues/58680
DROP TABLE IF EXISTS f32_table;
CREATE TABLE f32_table (my_field Float32) ENGINE=Memory();
INSERT INTO f32_table values ('49.9');
SELECT * FROM f32_table where my_field = '49.9';
DROP TABLE f32_table;