我使用一个默认的sysdate列在redshift中创建了一个表,但是当我插入数据时,我得到了一个奇怪的表达式,它的类型是character varying。这是我第一次遇到这个错误。
CREATE TABLE IF NOT EXISTS shipments_swp
(
shipment_id bigint DISTKEY ENCODE RAW,
user_id bigint ENCODE ZSTD,
last_tracking_event_time timestamp encode zstd,
bd_updated_at timestamp default sysdate ENCODE ZSTD
);
Insert into shipments_swp
(
select *
from common.shipments_dim
);错误消息如下所示
SQL Error [500310] [42804]: [Amazon](500310) Invalid operation: column "bd_updated_at" is of type timestamp without time zone but expression is of type character varying;发布于 2020-05-23 00:17:43
你能给出一个你想要插入到这个专栏中的时间戳的例子吗?在将其写入shipments_swp之前,您可能需要将该列转换为时间戳。我尝试了一个简单的测试,看看插入是否正确,插入没有任何问题:
CREATE TABLE IF NOT EXISTS test_table_a (
ts_a TIMESTAMP DEFAULT SYSDATE ENCODE ZSTD
);
-- Insert a few different date formats
insert into test_table_a values('2020/05/22');
insert into test_table_a values('2020-05-22');
insert into test_table_a values('2020-05-22 16:12:27.830728');
insert into test_table_a values('2020-05-22 16:06:00');
--- Create a second table and write to that
--- to mimic the insert behavior from the question
CREATE TABLE IF NOT EXISTS test_table_b (
ts_b TIMESTAMP DEFAULT SYSDATE ENCODE ZSTD
);
INSERT INTO test_table_b (
SELECT *
FROM test_table_a
);
--- This insert succeeds
SELECT * FROM test_table_b;
2020-05-22 16:06:00
2020-05-22 00:00:00
2020-05-22 16:06:56.823844
2020-05-22 00:00:00https://stackoverflow.com/questions/61940769
复制相似问题