create table XYZ(K Int64, A Float64 default NaN, B Nullable(Float64)) Engine=Memory;
insert into XYZ(K) values(1);
insert into XYZ(K, A, B) values(2, NaN, Null);
SELECT * FROM XYZ
┌─K─┬───A─┬────B─┐
│ 1 │ nan │ ᴺᵁᴸᴸ │
│ 2 │ nan │ ᴺᵁᴸᴸ │
└───┴─────┴──────┘
echo -e "3,N/A,N/A\n4,0.5,0.5"
3,N/A,N/A
4,0.5,0.5
echo -e "3,N/A,N/A\n4,0.5,0.5"|clickhouse-client -q "insert into XYZ SELECT K, ifNull(toFloat64OrNull(A),NaN), toFloat64OrNull(B) FROM input('K Int64, A String, B String') FORMAT CSV";
SELECT * FROM XYZ
┌─K─┬───A─┬────B─┐
│ 3 │ nan │ ᴺᵁᴸᴸ │
│ 4 │ 0.5 │ 0.5 │
└───┴─────┴──────┘
create table XYZ_null (K Int64, A String, B String) Engine=Null;
create materialized view XYZ_mv to XYZ as SELECT K, ifNull(toFloat64OrNull(A),NaN) A, toFloat64OrNull(B) B from XYZ_null
echo -e "5,N/A,N/A\n6,0.5,0.5"|clickhouse-client -q "insert into XYZ_null FORMAT CSV";
SELECT * FROM XYZ
┌─K─┬───A─┬────B─┐
│ 5 │ nan │ ᴺᵁᴸᴸ │
│ 6 │ 0.5 │ 0.5 │
└───┴─────┴──────┘
2条答案
按热度按时间h79rfbju1#
对于预处理输入数据,可以使用以下标准unix实用程序:
不适用->不适用
不适用->空
mqkwyuun2#