雪花 |插入覆盖失败,表达式类型与列数据类型不匹配,期望 TIMESTAMP_NTZ(9) 但列得到 FLOAT
Snowflake | Insert overwrite fails with Expression type does not match column data type, expecting TIMESTAMP_NTZ(9) but got FLOAT for column
尝试将具有 x+y 列的 table 中的覆盖数据插入具有 x+z 列的 table 并出现错误
SQL compilation error: Expression type does not match column data type, expecting TIMESTAMP_NTZ(9) but got FLOAT for column DATEMODIFIED
。
在这种情况下,两个 table 上 DATEMODIFIED 的数据类型都是 TIMESTAMP_NTZ(9)
。
查询如下
insert overwrite into tgt_table
select x1,x2,x3, DATEMODIFIED, null as z1, null as z2 from
(select x1,x2,x3, DATEMODIFIED from src_table)
- 来源的列描述 table
- 目标的列描述 table
注:
- Datemodified 在源 table 中为空,甚至将 DateModified 替换为
COALESCE(DateModified, CURRENT_TIMESTAMP::TIMESTAMP_NTZ) as DateModified
没有解决问题。
- 像下面这样重写查询并不能解决问题
insert overwrite into tgt_table
select x1,x2,x3, DATEMODIFIED::TIMESTAMP_NTZ as DateModified, null as z1, null as z2 from
(select x1,x2,x3, DATEMODIFIED::TIMESTAMP_NTZ as DateModified from src_table)
我怀疑目标 table 中列的顺序不同。
尝试在您的命令中定义目标列,如下所示:
insert overwrite into tgt_table (x1,x2,x3, DATEMODIFIED, z1, z2)
select x1,x2,x3, DATEMODIFIED, null as z1, null as z2 from
(select x1,x2,x3, DATEMODIFIED from src_table)
尝试将具有 x+y 列的 table 中的覆盖数据插入具有 x+z 列的 table 并出现错误
SQL compilation error: Expression type does not match column data type, expecting TIMESTAMP_NTZ(9) but got FLOAT for column DATEMODIFIED
。
在这种情况下,两个 table 上 DATEMODIFIED 的数据类型都是 TIMESTAMP_NTZ(9)
。
查询如下
insert overwrite into tgt_table
select x1,x2,x3, DATEMODIFIED, null as z1, null as z2 from
(select x1,x2,x3, DATEMODIFIED from src_table)
- 来源的列描述 table
- 目标的列描述 table
注:
- Datemodified 在源 table 中为空,甚至将 DateModified 替换为
COALESCE(DateModified, CURRENT_TIMESTAMP::TIMESTAMP_NTZ) as DateModified
没有解决问题。 - 像下面这样重写查询并不能解决问题
insert overwrite into tgt_table
select x1,x2,x3, DATEMODIFIED::TIMESTAMP_NTZ as DateModified, null as z1, null as z2 from
(select x1,x2,x3, DATEMODIFIED::TIMESTAMP_NTZ as DateModified from src_table)
我怀疑目标 table 中列的顺序不同。 尝试在您的命令中定义目标列,如下所示:
insert overwrite into tgt_table (x1,x2,x3, DATEMODIFIED, z1, z2)
select x1,x2,x3, DATEMODIFIED, null as z1, null as z2 from
(select x1,x2,x3, DATEMODIFIED from src_table)