CREATE TABLE orders (
order_id bigint NOT NULL COMMENT "订单ID",
dt date NOT NULL COMMENT "日期",
merchant_id int NOT NULL COMMENT "商家ID",
user_id int NOT NULL COMMENT "用户ID",
good_id int NOT NULL COMMENT "商品ID",
good_name string NOT NULL COMMENT "商品名称",
price int NOT NULL COMMENT "价格",
cnt int NOT NULL COMMENT "下单数量",
revenue int NOT NULL COMMENT "收入",
state tinyint NOT NULL COMMENT "订单状态",
detail JSON NULL COMMENT "订单详情",
note STRING NULL COMMENT "订单备注"
) ENGINE=OLAP
PRIMARY KEY (order_id,dt,merchant_id)
PARTITION BY date_trunc('day', dt)
DISTRIBUTED BY HASH (merchant_id)
ORDER BY (dt,merchant_id)
PROPERTIES (
"enable_persistent_index" = "true",
"compression" = "ZSTD",
"replication_num" = "1",
"storage_format" = "DEFAULT",
"bloom_filter_columns" = "note,good_name"
);
select * from orders where note = '订单';
INSERT INTO demo.orders (order_id, dt, merchant_id, user_id, good_id, good_name, price, cnt, revenue, state, detail, note) VALUES(1, '2024-12-02', 123, 456, 789, 'apple', 1200, 9, 10000, 1, '{"name":"aa"}', '订单');
INSERT INTO demo.orders (order_id, dt, merchant_id, user_id, good_id, good_name, price, cnt, revenue, state, detail, note) VALUES(2, '2024-12-02', 123, 456, 789, 'oracle', 1200, 9, 10000, 1, '{"name":"bb"}', '订单');
docker run -itd --name my-redis --user=root --restart unless-stopped -p 6379:6379 -w /opt/ --privileged=true my-redis:7.2.5