在trino模式下使用TO_UNIXTIME 函数 在 insert into … select … 场景下 兼容报错
测试步骤如下:
- 在查询select * from 场景下 TO_UNIXTIME、FROM_UNIXTIME 正常
set sql_dialect = 'trino';
SELECT TO_UNIXTIME(jcsj_datetime) as unx,FROM_UNIXTIME(jcsj_bigint) as dt from mou_test_source ;
- 在insert into … select … 场景下 TO_UNIXTIME 【报错】
set sql_dialect = 'trino';
insert into mou_test_target(c1_bigint,c2_datetime)
SELECT TO_UNIXTIME(jcsj_datetime) as unx, FROM_UNIXTIME(jcsj_bigint) as dt from mou_test_source ;
set sql_dialect = 'trino';
insert into mou_test_target(c1_bigint,c2_datetime)
SELECT 1590940801 as unx, '2024-04-18 15:49:37' as dt
mou_test_source与mou_test_target建表语句如下:
CREATE TABLE `mou_test_source` (
`jcsj_bigint` bigint(20) NULL COMMENT "检测时间",
`jcsj_datetime` datetime NULL COMMENT "检测时间戳"
) ENGINE=OLAP
DUPLICATE KEY(`jcsj_bigint`)
DISTRIBUTED BY RANDOM
PROPERTIES (
"replication_num" = "3",
"in_memory" = "false",
"enable_persistent_index" = "false",
"replicated_storage" = "true",
"compression" = "LZ4"
);
CREATE TABLE `mou_test_target` (
`c1_bigint` bigint(20) NULL COMMENT "c1",
`c2_datetime` datetime NULL COMMENT "c2"
) ENGINE=OLAP
DUPLICATE KEY(`c1_bigint`)
DISTRIBUTED BY RANDOM
PROPERTIES (
"replication_num" = "3",
"in_memory" = "false",
"enable_persistent_index" = "false",
"replicated_storage" = "true",
"compression" = "LZ4"
);;