For example, I've a table with only 2 columns:
Table columns | Data type |
---|---|
Date | Datetime |
Values | Float32 |
But when I want to insert an integer to the column "Values", script crashes. Yes, I do know that it only accepts the Float32 datatype.
So the question is, which datatype to choose, in order column "Values" accept both Float and Integer Values (if it's possible)?
can't get more info from your question.
But I tried Datatype of Decimal32
, then integer and float can be inserted.
The Sql is:
-- create local table and distributed table
create table test_decimal on cluster default (name String, value Decimal32(8), created_at Datetime) ENGINE = MergeTree() order by name;
create table test_decimal_d on cluster default (name String, value Decimal32(8), created_at Datetime) ENGINE = Distributed('default', 'default', 'test_decimal', xxHash64(name));
-- insert data
INSERT into test_decimal_d values ('name1', 1.0, '2021-12-17 09:46:00');
INSERT into test_decimal_d values ('name2', 2, '2021-12-17 09:46:01');