Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tianmu): backport support union different datetime type #1743 #1811

Merged
merged 1 commit into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mysql-test/suite/tianmu/r/delete_all_rows.result
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ sum(c_int)
# DELETE FROM TABLE_NAME for select/insert/Aggregate query
#
#
# DELETE FROM column_type_test spend too much time, optimize it later (#TODO)
# DELETE FROM column_type_test spend too much time, optimize it later
#
drop table column_type_test;
CREATE TABLE `column_type_test` (
Expand Down
370 changes: 359 additions & 11 deletions mysql-test/suite/tianmu/r/issue880.result

Large diffs are not rendered by default.

103 changes: 103 additions & 0 deletions mysql-test/suite/tianmu/r/union.result
Original file line number Diff line number Diff line change
Expand Up @@ -471,4 +471,107 @@ a
78
910
DROP TABLE t1,t2;
CREATE TABLE t1 (a datetime);
INSERT INTO t1 VALUES ("2022-08-20 12:00:00"),("2022-08-21 12:00:00"),("2022-08-22 12:00:00"),("2022-08-23 12:00:00");
CREATE TABLE t2 (a timestamp);
INSERT INTO t2 VALUES ("2021-07-20 12:30:00"),("2021-07-21 12:30:00"),("2021-07-22 12:30:00"),("2021-07-23 12:30:00");
CREATE TABLE t3 (a date);
INSERT INTO t3 VALUES ("2020-06-10"),("2020-06-11"),("2020-06-12"),("2020-06-13");
SELECT a FROM t1 UNION SELECT a FROM t2;
a
2022-08-20 15:00:00
2022-08-21 15:00:00
2022-08-22 15:00:00
2022-08-23 15:00:00
2021-07-20 12:30:00
2021-07-21 12:30:00
2021-07-22 12:30:00
2021-07-23 12:30:00
SELECT a FROM t2 UNION SELECT a FROM t1;
a
2021-07-20 09:30:00
2021-07-21 09:30:00
2021-07-22 09:30:00
2021-07-23 09:30:00
2022-08-20 12:00:00
2022-08-21 12:00:00
2022-08-22 12:00:00
2022-08-23 12:00:00
SELECT a FROM t1 where a is null UNION SELECT a FROM t2;
a
2021-07-20 12:30:00
2021-07-21 12:30:00
2021-07-22 12:30:00
2021-07-23 12:30:00
SELECT a FROM t1 UNION SELECT a FROM t2 where a is null;
a
2022-08-20 15:00:00
2022-08-21 15:00:00
2022-08-22 15:00:00
2022-08-23 15:00:00
SELECT a FROM t1 UNION SELECT a FROM t3;
a
2022-08-20 12:00:00
2022-08-21 12:00:00
2022-08-22 12:00:00
2022-08-23 12:00:00
2020-06-10 00:00:00
2020-06-11 00:00:00
2020-06-12 00:00:00
2020-06-13 00:00:00
SELECT a FROM t3 UNION SELECT a FROM t1;
a
2020-06-10 00:00:00
2020-06-11 00:00:00
2020-06-12 00:00:00
2020-06-13 00:00:00
2022-08-20 12:00:00
2022-08-21 12:00:00
2022-08-22 12:00:00
2022-08-23 12:00:00
SELECT a FROM t1 where a is null UNION SELECT a FROM t3;
a
2020-06-10 00:00:00
2020-06-11 00:00:00
2020-06-12 00:00:00
2020-06-13 00:00:00
SELECT a FROM t1 UNION SELECT a FROM t3 where a is null;
a
2022-08-20 12:00:00
2022-08-21 12:00:00
2022-08-22 12:00:00
2022-08-23 12:00:00
SELECT a FROM t2 UNION SELECT a FROM t3;
a
2021-07-20 12:30:00
2021-07-21 12:30:00
2021-07-22 12:30:00
2021-07-23 12:30:00
2020-06-10 03:00:00
2020-06-11 03:00:00
2020-06-12 03:00:00
2020-06-13 03:00:00
SELECT a FROM t3 UNION SELECT a FROM t2;
a
2020-06-10 03:00:00
2020-06-11 03:00:00
2020-06-12 03:00:00
2020-06-13 03:00:00
2021-07-20 12:30:00
2021-07-21 12:30:00
2021-07-22 12:30:00
2021-07-23 12:30:00
SELECT a FROM t2 where a is null UNION SELECT a FROM t3;
a
2020-06-10 03:00:00
2020-06-11 03:00:00
2020-06-12 03:00:00
2020-06-13 03:00:00
SELECT a FROM t2 UNION SELECT a FROM t3 where a is null;
a
2021-07-20 12:30:00
2021-07-21 12:30:00
2021-07-22 12:30:00
2021-07-23 12:30:00
DROP TABLE t1,t2,t3;
DROP DATABASE union_test;
26,068 changes: 26,068 additions & 0 deletions mysql-test/suite/tianmu/std_data/issue880_t1.txt

Large diffs are not rendered by default.

25,109 changes: 25,109 additions & 0 deletions mysql-test/suite/tianmu/std_data/issue880_t2.txt

Large diffs are not rendered by default.

1,227 changes: 1,227 additions & 0 deletions mysql-test/suite/tianmu/std_data/issue880_t3.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion mysql-test/suite/tianmu/t/delete_all_rows.test
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ select sum(c_int) from column_type_test;
--echo #

--echo #
--echo # DELETE FROM column_type_test spend too much time, optimize it later (#TODO)
--echo # DELETE FROM column_type_test spend too much time, optimize it later
--echo #

drop table column_type_test;
Expand Down
1 change: 1 addition & 0 deletions mysql-test/suite/tianmu/t/issue880-master.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--local-infile
194 changes: 185 additions & 9 deletions mysql-test/suite/tianmu/t/issue880.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,198 @@
--echo # support (not timestamp union not timestamp)
--echo # support (timestamp union varchar)
--echo # support (varchar union timestamp)
--echo # not support (timestamp union datetime)
--echo # not support (datetime union timestamp)
--echo # support (timestamp union datetime)
--echo # support (datetime union timestamp)
--echo # not support (timestamp union other type)
--echo # not support (other type union timestamp)
--echo # SELECT timestamp_type/other_type FROM tablename union SELECT timestamp_type/other_type FROM tablename

--disable_warnings
DROP DATABASE IF EXISTS test_timestamp_union;
--enable_warnings

CREATE DATABASE test_timestamp_union;
USE test_timestamp_union;
create table t1(a datetime);
create table t2(b timestamp);
insert into t1 values('2020-12-23 00:00:00');
insert into t2 values('2022-04-18 00:00:00');
select * from t1 union select * from t2;

drop database test_timestamp_union;
CREATE TABLE `issue880_t1` (
`id` int NOT NULL COMMENT '主键; Size[MB]: 0.1; Ratio: 1.00',
`company_account_id` int DEFAULT NULL COMMENT 'tb_finance_company_account表主键; Size[MB]: 0.1; Ratio: 2.06',
`period_account_id` int DEFAULT NULL COMMENT '核账ID; Size[MB]: 0.1; Ratio: 1.78',
`COMPANY_ID` int DEFAULT NULL COMMENT '公司id; Size[MB]: 0.1; Ratio: 1.78',
`BALANCE` decimal(10,2) DEFAULT NULL COMMENT '变动的余额; Size[MB]: 0.1; Ratio: 2.78',
`before_balance` decimal(10,2) DEFAULT NULL COMMENT '变动前的余额; Size[MB]: 0.1; Ratio: 2.78',
`after_balance` decimal(10,2) DEFAULT NULL COMMENT '变动后的余额; Size[MB]: 0.1; Ratio: 2.78',
`create_time` timestamp NULL DEFAULT NULL COMMENT 'Size[MB]: 0.1; Ratio: 2.39\0 ',
`update_time` datetime DEFAULT NULL COMMENT 'Size[MB]: 0.1; Ratio: 2.39\0 ',
`type` smallint DEFAULT NULL COMMENT '交易类型(1线下核帐成功、2易宝代付成功,3易宝代付失败,4,每天抽佣,5每月抽佣,6每季度抽佣,7每年抽佣,8易宝手续费,9在线充值,10在线退款,11Saas产品购买,13补贴结算,14政府补贴到账,15运营商专项补贴 ,17余额冲正); Size[MB]: 0.1; Ratio: 2.12',
`order_sn` varchar(100) DEFAULT NULL COMMENT '余额明细的订单编号; Size[MB]: 0.6; Ratio: 0.79',
`third_sn` varchar(45) DEFAULT NULL COMMENT '第三方流水号; Size[MB]: 0.1; Ratio: 0.00',
`commission_period` smallint DEFAULT NULL COMMENT '抽佣周期. T+1 1, 按月结算 2, 按季度结算 3, 按年结算 4; Size[MB]: 0.1; Ratio: 1.62',
`detail_period_time` varchar(45) DEFAULT NULL COMMENT ' T+1:(2018-10-12) , 按月结算:(1-12) , 按季度结算:(1,2,3,4), 按年结算(2018); Size[MB]: 0.1; Ratio: 0.00',
`period_pay_id` int DEFAULT NULL COMMENT 'Size[MB]: 0.1; Ratio: 1.78\0 ',
`operator_time` datetime DEFAULT NULL COMMENT '操作时间; Size[MB]: 0.2; Ratio: 2.30',
`operator` varchar(50) DEFAULT NULL COMMENT '操作人; Size[MB]: 0.1; Ratio: 0.02',
`operator_id` int DEFAULT NULL COMMENT '操作人id; Size[MB]: 0.1; Ratio: 1.78',
`remark` varchar(50) DEFAULT NULL COMMENT '备注; Size[MB]: 0.1; Ratio: 0.02',
PRIMARY KEY (`id`),
UNIQUE KEY `company_account_change_id` (`id`),
KEY `company_change_company_id` (`COMPANY_ID`),
KEY `period_pay_id_index` (`period_pay_id`),
KEY `period_account_id_index` (`period_account_id`)
) ENGINE=TIANMU DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED;


CREATE TABLE `issue880_t2` (
`id` int NOT NULL COMMENT 'Size[MB]: 0.1; Ratio: 2.00\0 ',
`company_id` int DEFAULT NULL COMMENT '公司ID; Size[MB]: 0.1; Ratio: 2.06',
`company_name` varchar(250) DEFAULT NULL COMMENT '公司名称; Size[MB]: 0.5; Ratio: 0.77',
`product_id` int DEFAULT NULL COMMENT 'Size[MB]: 0.1; Ratio: 1.77\0 ',
`product_name` varchar(60) DEFAULT NULL COMMENT 'Size[MB]: 0.4; Ratio: 0.72\0 ',
`pay_type` smallint NOT NULL DEFAULT '2' COMMENT '支付方式(1:支出,2:收入); Size[MB]: 0.1; Ratio: 2.00',
`pay_account` varchar(45) DEFAULT NULL COMMENT '支付账户; Size[MB]: 0.5; Ratio: 0.73',
`bank_code` varchar(10) DEFAULT NULL COMMENT '银行编号; Size[MB]: 0.2; Ratio: 0.39',
`poundage_mode` smallint DEFAULT NULL COMMENT '''手续费方式(运营商支付:1,平台支付:2)''; Size[MB]: 0.1; Ratio: 1.60',
`commission_period` smallint NOT NULL COMMENT '''抽佣周期. T+1 1, 按月结算 2, 按季度结算 3, 按年结算 4'',运营商专项补贴5,订阅结算6,每日结算抽佣7,每月结算抽佣8; Size[MB]: 0.1; Ratio: 2.00',
`create_time` timestamp NULL DEFAULT NULL COMMENT 'Size[MB]: 0.1; Ratio: 2.30\0 ',
`update_time` timestamp NULL DEFAULT NULL COMMENT 'Size[MB]: 0.1; Ratio: 2.39\0 ',
`maid_type` smallint DEFAULT NULL COMMENT '抽佣类型(1:平台抽佣,2:承担手续费); Size[MB]: 0.1; Ratio: 0.91',
`guarantee_amount` decimal(10,2) DEFAULT '0.00' COMMENT '保底金额; Size[MB]: 0.1; Ratio: 2.57',
`guarantee_extra_amount` decimal(10,4) DEFAULT '0.0000' COMMENT '额外支付金额; Size[MB]: 0.1; Ratio: 2.57',
`period_account_money` decimal(10,2) DEFAULT '0.00' COMMENT '分账结果; Size[MB]: 0.1; Ratio: 2.57',
`fee` decimal(10,2) DEFAULT NULL COMMENT '手续费; Size[MB]: 0.1; Ratio: 8.39',
`fee_type` varchar(10) DEFAULT NULL COMMENT '手续费类型; Size[MB]: 0.1; Ratio: 0.02',
`poundage_money` decimal(10,4) DEFAULT NULL COMMENT '手续费; Size[MB]: 0.1; Ratio: 2.57',
`sum_expense` decimal(10,2) DEFAULT NULL COMMENT '总金额; Size[MB]: 0.1; Ratio: 2.57',
`sum_electric_charge` decimal(10,3) DEFAULT NULL COMMENT '总电量; Size[MB]: 0.1; Ratio: 2.57',
`sum_service_charge` decimal(10,2) DEFAULT NULL COMMENT '总服务费; Size[MB]: 0.1; Ratio: 2.57',
`sum_earning_money` decimal(10,4) DEFAULT NULL COMMENT '总抽佣钱; Size[MB]: 0.1; Ratio: 2.57',
`begin_data_time` date DEFAULT NULL COMMENT '分账开始日期; Size[MB]: 0.1; Ratio: 1.22',
`end_data_time` date DEFAULT NULL COMMENT '分账结束日期; Size[MB]: 0.1; Ratio: 1.22',
`pay_status` smallint DEFAULT '0' COMMENT '支付状态(0:未支付,1:支付调用,2:支付成功,3:支付失败); Size[MB]: 0.1; Ratio: 1.06',
`fail_msg` varchar(250) DEFAULT NULL COMMENT 'Size[MB]: 0.1; Ratio: 0.02\0 ',
`batch_no` varchar(30) DEFAULT NULL COMMENT '批次号; Size[MB]: 0.5; Ratio: 0.75',
`order_no` varchar(30) DEFAULT NULL COMMENT '订单号; Size[MB]: 0.6; Ratio: 0.79',
`period_operator` varchar(40) DEFAULT NULL COMMENT '核账确认用户; Size[MB]: 0.1; Ratio: 0.03',
`period_time` datetime DEFAULT NULL COMMENT '核账时间; Size[MB]: 0.1; Ratio: 2.30',
`period_status` smallint DEFAULT '0' COMMENT '线下核账状态,(0:未核账,1:已核账); Size[MB]: 0.1; Ratio: 1.60',
`out_sum_charge` decimal(10,3) DEFAULT '0.000' COMMENT '对外总电量; Size[MB]: 0.1; Ratio: 2.57',
`out_sum_earning_money` decimal(10,4) DEFAULT '0.0000' COMMENT '对外总抽佣; Size[MB]: 0.1; Ratio: 2.78',
`out_sum_money` decimal(10,4) DEFAULT '0.0000' COMMENT '对外总金额; Size[MB]: 0.1; Ratio: 2.78',
`in_sum_charge` decimal(10,3) DEFAULT '0.000' COMMENT '对内总电量; Size[MB]: 0.1; Ratio: 2.78',
`in_sum_earning_money` decimal(10,4) DEFAULT '0.0000' COMMENT '对内总抽佣; Size[MB]: 0.1; Ratio: 2.78',
`in_sum_money` decimal(10,4) DEFAULT '0.0000' COMMENT '对内总金额; Size[MB]: 0.1; Ratio: 2.78',
`period_pay_id` int DEFAULT NULL COMMENT 'Size[MB]: 0.1; Ratio: 1.77\0 ',
`order_source` varchar(255) DEFAULT NULL COMMENT '订单来源,多个以逗号分隔; Size[MB]: 0.1; Ratio: 0.02',
`sum_subsidy_monetary` decimal(10,2) DEFAULT '0.00' COMMENT '总补贴金额; Size[MB]: 0.1; Ratio: 8.39',
`subscribe_number` varchar(5000) DEFAULT NULL COMMENT '订阅编号; Size[MB]: 0.1; Ratio: 0.04',
`settlement_status` smallint DEFAULT '1' COMMENT '是否需要结算0不需要,1需要; Size[MB]: 0.1; Ratio: 1.60',
`company_type` smallint DEFAULT '1' COMMENT '公司类型(1:运营商,2:合作伙伴); Size[MB]: 0.1; Ratio: 2.12',
PRIMARY KEY (`id`),
UNIQUE KEY `period_account_id` (`id`),
KEY `period_account_company_id` (`company_id`),
KEY `index_pay_type` (`pay_type`),
KEY `index_pay_status` (`pay_status`),
KEY `index_type_status` (`pay_type`,`pay_status`)
) ENGINE=TIANMU DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED;

CREATE TABLE `issue880_t3` (
`id` int NOT NULL COMMENT 'Size[MB]: 0.1; Ratio: 2.00\0 ',
`company_id` int DEFAULT NULL COMMENT 'Size[MB]: 0.1; Ratio: 2.06\0 ',
`company_name` varchar(40) DEFAULT NULL COMMENT 'Size[MB]: 0.1; Ratio: 0.20\0 ',
`poundage_mode` smallint DEFAULT NULL COMMENT '支付方式(1:支出,2:收入); Size[MB]: 0.1; Ratio: 2.12',
`money` decimal(10,2) DEFAULT NULL COMMENT 'Size[MB]: 0.1; Ratio: 2.78\0 ',
`pay_status` smallint DEFAULT NULL COMMENT '支付状态(0:未支付,1:支付调用,2:支付成功,3:支付失败); Size[MB]: 0.1; Ratio: 2.12',
`fail_msg` varchar(250) DEFAULT NULL COMMENT 'Size[MB]: 0.1; Ratio: 0.02\0 ',
`batch_no` varchar(30) DEFAULT NULL COMMENT 'Size[MB]: 0.1; Ratio: 0.12\0 ',
`fee` decimal(10,2) DEFAULT NULL COMMENT '手续费; Size[MB]: 0.1; Ratio: 0.76',
`fee_type` varchar(10) DEFAULT NULL COMMENT '手续费类型; Size[MB]: 0.1; Ratio: 0.05',
`order_no` varchar(30) DEFAULT NULL COMMENT 'Size[MB]: 0.1; Ratio: 0.15\0 ',
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Size[MB]: 0.1; Ratio: 2.39\0 ',
`success_time` datetime DEFAULT NULL COMMENT '成功时间; Size[MB]: 0.1; Ratio: 1.30',
`source` smallint DEFAULT '0' COMMENT '代付订单来源:0抽佣结算,1政府补贴; Size[MB]: 0.1; Ratio: 0.24',
`period_account_id` int DEFAULT NULL COMMENT '分账ID; Size[MB]: 0.1; Ratio: 0.48',
`account_number` varchar(20) DEFAULT NULL COMMENT '交易银行账户; Size[MB]: 0.1; Ratio: 0.04',
`pay_flag` smallint DEFAULT '0' COMMENT '是否需要支付,0需要,1不需要; Size[MB]: 0.1; Ratio: 0.24',
`union_order_flag` smallint DEFAULT '0' COMMENT '是否合成订单0不是,1是; Size[MB]: 0.1; Ratio: 2.12',
PRIMARY KEY (`id`),
UNIQUE KEY `pay_id` (`id`),
UNIQUE KEY `pay_order_no` (`order_no`),
KEY `pay_status_index` (`pay_status`),
KEY `idx_pay_status_feetype` (`pay_status`,`fee_type`)
) ENGINE=TIANMU DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED;
--enable_warnings
# load data issue880_t1
LOAD DATA LOCAL INFILE 'suite/tianmu/std_data/issue880_t1.txt' INTO TABLE issue880_t1;

# load data issue880_t3
LOAD DATA LOCAL INFILE 'suite/tianmu/std_data/issue880_t3.txt' INTO TABLE issue880_t3;

# load data issue880_t2
LOAD DATA LOCAL INFILE 'suite/tianmu/std_data/issue880_t2.txt' INTO TABLE issue880_t2;

# test timestamp union timestamp
select b.create_time AS create_time
from (issue880_t3 a join issue880_t1 b)
where ((a.id = b.period_pay_id) and (a.pay_status = 2) and
(a.fee_type = 'TARGET') and (b.type = 2))
union
select a.create_time AS create_time
from (issue880_t2 a join issue880_t1 b)
where ((a.id = b.period_account_id) and (b.type = 1) and (a.pay_type = 1) and
(a.period_status = 1));

# test not timestamp union not timestamp
select b.update_time AS create_time
from (issue880_t3 a join issue880_t1 b)
where ((a.id = b.period_pay_id) and (a.pay_status = 2) and
(a.fee_type = 'TARGET') and (b.type = 2))
union
select a.period_time AS create_time
from (issue880_t2 a join issue880_t1 b)
where ((a.id = b.period_account_id) and (b.type = 1) and (a.pay_type = 1) and
(a.period_status = 1));

# test timestamp union datetime
select b.CREATE_TIME AS create_time
from (issue880_t3 a join issue880_t1 b)
where ((a.id = b.period_pay_id) and (a.pay_status = 2) and
(a.fee_type = 'TARGET') and (b.type = 2))
union
select a.period_time AS create_time
from (issue880_t2 a join issue880_t1 b)
where ((a.id = b.period_account_id) and (b.type = 1) and (a.pay_type = 1) and
(a.period_status = 1));

# test datetime union timestamp
select b.update_time AS create_time
from (issue880_t3 a join issue880_t1 b)
where ((a.id = b.period_pay_id) and (a.pay_status = 2) and
(a.fee_type = 'TARGET') and (b.type = 2))
union
select a.create_time AS create_time
from (issue880_t2 a join issue880_t1 b)
where ((a.id = b.period_account_id) and (b.type = 1) and (a.pay_type = 1) and
(a.period_status = 1));

# TODO: varchar union timestamp and timestamp union varchar
# select b.order_sn AS create_time
# from (issue880_t3 a join issue880_t1 b)
# where ((a.id = b.period_pay_id) and (a.pay_status = 2) and
# (a.fee_type = 'TARGET') and (b.type = 2))
# union
# select a.create_time AS create_time
# from (issue880_t2 a join issue880_t1 b)
# where ((a.id = b.period_account_id) and (b.type = 1) and (a.pay_type = 1) and
# (a.period_status = 1));
#
# select b.create_time AS create_time
# from (issue880_t3 a join issue880_t1 b)
# where ((a.id = b.period_pay_id) and (a.pay_status = 2) and
# (a.fee_type = 'TARGET') and (b.type = 2))
# union
# select a.product_name AS create_time
# from (issue880_t2 a join issue880_t1 b)
# where ((a.id = b.period_account_id) and (b.type = 1) and (a.pay_type = 1) and
# (a.period_status = 1));

# clean up
DROP DATABASE test_timestamp_union;
28 changes: 28 additions & 0 deletions mysql-test/suite/tianmu/t/union.test
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,32 @@ INSERT INTO t2 VALUES ("12"),("34"),("56"),("78"),("910");
SELECT a FROM t1 UNION ALL SELECT a FROM t2;
DROP TABLE t1,t2;

CREATE TABLE t1 (a datetime);
INSERT INTO t1 VALUES ("2022-08-20 12:00:00"),("2022-08-21 12:00:00"),("2022-08-22 12:00:00"),("2022-08-23 12:00:00");
CREATE TABLE t2 (a timestamp);
INSERT INTO t2 VALUES ("2021-07-20 12:30:00"),("2021-07-21 12:30:00"),("2021-07-22 12:30:00"),("2021-07-23 12:30:00");
CREATE TABLE t3 (a date);
INSERT INTO t3 VALUES ("2020-06-10"),("2020-06-11"),("2020-06-12"),("2020-06-13");

# datetime union timestamp
SELECT a FROM t1 UNION SELECT a FROM t2;
SELECT a FROM t2 UNION SELECT a FROM t1;
SELECT a FROM t1 where a is null UNION SELECT a FROM t2;
SELECT a FROM t1 UNION SELECT a FROM t2 where a is null;


# datetime union date
SELECT a FROM t1 UNION SELECT a FROM t3;
SELECT a FROM t3 UNION SELECT a FROM t1;
SELECT a FROM t1 where a is null UNION SELECT a FROM t3;
SELECT a FROM t1 UNION SELECT a FROM t3 where a is null;

# timestamp union date
SELECT a FROM t2 UNION SELECT a FROM t3;
SELECT a FROM t3 UNION SELECT a FROM t2;
SELECT a FROM t2 where a is null UNION SELECT a FROM t3;
SELECT a FROM t2 UNION SELECT a FROM t3 where a is null;

DROP TABLE t1,t2,t3;

DROP DATABASE union_test;
Loading