spark寫入欄位有default timestamp卻不起作用

Viewed 70

doris table ddl如下

CREATE TABLE Mysql_CDC_orders_test (
    origin_table VARCHAR,
    id  BIGINT,
    date_utc8 DATE,
    auto_id BIGINT NOT NULL AUTO_INCREMENT,
    commit_datetime datetime default current_timestamp(0) on update current_timestamp(0),
    status  INT,
    user_id  BIGINT,
    price  DECIMAL(38,0)
)
UNIQUE KEY(`origin_table`,`id`,`date_utc8`)
DISTRIBUTED BY HASH(`date_utc8`) BUCKETS AUTO
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"enable_unique_key_merge_on_write" = "true"
);

使用spark connector導入數據進doris時,commit_datetime欄位會是空值,理論上應該會自動填入default current_timestamp(0),但卻沒有,請問可能是什麼問題呢?如果將commit_datetime設成not null,則在be log會出現

Reason: column(commit_datetime) values is null while columns is not nullable.

spark sql如下

INSERT INTO test (origin_table,id, date_utc8, status, user_id, price) VALUES ('test',2,current_date(),0,0,200);

Doris版本2.1.1,從helm k8s部署
spark connector版本1.3.1

1 Answers

这块有可能是使用问题,commit_datetime这一列的数据不应该带双引号,可以看下你的数据