【问题现象】
使用datax,编写jobjson,从gp(greenplum)库抽到pg(postgreSQL)库的增量语句(gp库及pg库中的updatet_dt字段均为timestamp类型):
"querySql": [
"select 字段名 from 表名
where update_dt >= to_char(to_timestamp(${lastTime}),'yyyy-MM-dd HH24:MI:SS')
AND update_dt < to_char(to_timestamp(${currentTime}),'yyyy-MM-dd HH24:MI:SS')"
],
运行后报错,
具体错误信息为:
“org.postgresql.util.PSQLException: ERROR: operator does not exist: timestamp without time zone >= text”
【解决方法】
将增量jobjson的sql语句的日期格式化部分最后加::TIMESTAMP,如下所示:
"querySql": [
"select 字段名 from 表名 where
update_dt >= to_char(to_timestamp(${lastTime}),'yyyy-MM-dd HH24:MI:SS')::TIMESTAMP
and update_dt < to_char(to_timestamp(${currentTime}),'yyyy-MM-dd HH24:MI:SS')::TIMESTAMP"
],