ClickHouse/tests/queries/0_stateless/01909_mbtolou.sql

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
339 KiB
MySQL
Raw Normal View History

2021-06-13 22:58:06 +00:00
-- BIGMDM.DATE_INFO_DICT definition
DROP TABLE IF EXISTS DATE_INFO_DICT;
CREATE TABLE DATE_INFO_DICT
(
`TV` Date,
`SHAMSI` String,
`HIJRI` String,
`MILADI` String,
`S_DAY` UInt8,
`H_DAY` UInt8,
`S_MONTH` UInt8,
`H_MONTH` UInt8,
`WEEK_DAY_NAME` String,
`DAY_NUMBER` UInt8,
`HOLIDAY` UInt8,
`WEEK_NAME` String
)
ENGINE = Join(ANY, LEFT, TV);
truncate table DATE_INFO_DICT;
INSERT INTO DATE_INFO_DICT (TV, SHAMSI, HIJRI, MILADI, S_DAY, H_DAY, S_MONTH, H_MONTH, WEEK_DAY_NAME, DAY_NUMBER, HOLIDAY, WEEK_NAME) VALUES ('2017-04-01', '1396-01-12', '1438-07-04', '2017-04-01', 12, 4, 1, 7, 'saturday ', 7, 0, 'NONE') ,('2017-04-02', '1396-01-13', '1438-07-05', '2017-04-02', 13, 5, 1, 7, 'sunday ', 1, 0, 'NONE') ,('2017-04-03', '1396-01-14', '1438-07-06', '2017-04-03', 14, 6, 1, 7, 'monday ', 2, 0, 'NONE') ,('2017-04-04', '1396-01-15', '1438-07-07', '2017-04-04', 15, 7, 1, 7, 'tuesday ', 3, 0, 'NONE') ,('2017-04-05', '1396-01-16', '1438-07-08', '2017-04-05', 16, 8, 1, 7, 'wednesday', 4, 0, 'NONE') ,('2017-04-06', '1396-01-17', '1438-07-09', '2017-04-06', 17, 9, 1, 7, 'thursday ', 5, 0, 'NONE') ,('2017-04-07', '1396-01-18', '1438-07-10', '2017-04-07', 18, 10, 1, 7, 'friday ', 6, 0, 'NONE') ,('2017-04-08', '1396-01-19', '1438-07-11', '2017-04-08', 19, 11, 1, 7, 'saturday ', 7, 0, 'NONE') ,('2017-04-09', '1396-01-20', '1438-07-12', '2017-04-09', 20, 12, 1, 7, 'sunday ', 1, 0, 'NONE') ,('2017-04-10', '1396-01-21', '1438-07-13', '2017-04-10', 21, 13, 1, 7, 'monday ', 2, 0, 'NONE') ,('2017-04-11', '1396-01-22', '1438-07-14', '2017-04-11', 22, 14, 1, 7, 'tuesday ', 3, 0, 'NONE') ,('2017-04-12', '1396-01-23', '1438-07-15', '2017-04-12', 23, 15, 1, 7, 'wednesday', 4, 0, 'NONE') ,('2017-04-13', '1396-01-24', '1438-07-16', '2017-04-13', 24, 16, 1, 7, 'thursday ', 5, 0, 'NONE') ,('2017-04-14', '1396-01-25', '1438-07-17', '2017-04-14', 25, 17, 1, 7, 'friday ', 6, 0, 'NONE') ,('2017-04-15', '1396-01-26', '1438-07-18', '2017-04-15', 26, 18, 1, 7, 'saturday ', 7, 0, 'NONE') ,('2017-04-16', '1396-01-27', '1438-07-19', '2017-04-16', 27, 19, 1, 7, 'sunday ', 1, 0, 'NONE') ,('2017-04-17', '1396-01-28', '1438-07-20', '2017-04-17', 28, 20, 1, 7, 'monday ', 2, 0, 'NONE') ,('2017-04-18', '1396-01-29', '1438-07-21', '2017-04-18', 29, 21, 1, 7, 'tuesday ', 3, 0, 'NONE') ,('2017-04-19', '1396-01-30', '1438-07-22', '2017-04-19', 30, 22, 1, 7, 'wednesday', 4, 0, 'NONE') ,('2017-04-20', '1396-01-31', '1438-07-23', '2017-04-20', 31, 23, 1, 7, 'thursday ', 5, 0, 'NONE') ,('2017-04-21', '1396-02-01', '1438-07-24', '2017-04-21', 1, 24, 2, 7, 'friday ', 6, 0, 'NONE') ,('2017-04-22', '1396-02-02', '1438-07-25', '2017-04-22', 2, 25, 2, 7, 'saturday ', 7, 0, 'NONE') ,('2017-04-23', '1396-02-03', '1438-07-26', '2017-04-23', 3, 26, 2, 7, 'sunday ', 1, 0, 'NONE') ,('2017-04-24', '1396-02-04', '1438-07-27', '2017-04-24', 4, 27, 2, 7, 'monday ', 2, 0, 'NONE') ,('2017-04-25', '1396-02-05', '1438-07-28', '2017-04-25', 5, 28, 2, 7, 'tuesday ', 3, 0, 'NONE') ,('2017-04-26', '1396-02-06', '1438-07-29', '2017-04-26', 6, 29, 2, 7, 'wednesday', 4, 0, 'NONE') ,('2017-04-27', '1396-02-07', '1438-07-30', '2017-04-27', 7, 30, 2, 7, 'thursday ', 5, 0, 'NONE') ,('2017-04-28', '1396-02-08', '1438-08-01', '2017-04-28', 8, 1, 2, 8, 'friday ', 6, 0, 'NONE') ,('2017-04-29', '1396-02-09', '1438-08-02', '2017-04-29', 9, 2, 2, 8, 'saturday ', 7, 0, 'NONE') ,('2017-04-30', '1396-02-10', '1438-08-03', '2017-04-30', 10, 3, 2, 8, 'sunday ', 1, 0, 'NONE') ,('2017-05-01', '1396-02-11', '1438-08-04', '2017-05-01', 11, 4, 2, 8, 'monday ', 2, 0, 'NONE') ,('2017-05-02', '1396-02-12', '1438-08-05', '2017-05-02', 12, 5, 2, 8, 'tuesday ', 3, 0, 'NONE') ,('2017-05-03', '1396-02-13', '1438-08-06', '2017-05-03', 13, 6, 2, 8, 'wednesday', 4, 0, 'NONE') ,('2017-05-04', '1396-02-14', '1438-08-07', '2017-05-04', 14, 7, 2, 8, 'thursday ', 5, 0, 'NONE') ,('2017-05-05', '1396-02-15', '1438-08-08', '2017-05-05', 15, 8, 2, 8, 'friday ', 6, 0, 'NONE') ,('2017-05-06', '1396-02-16', '1438-08-09', '2017-05-06', 16, 9, 2, 8, 'saturday ', 7, 0, 'NONE') ,('2017-05-07', '1396-02-17', '1438-08-10', '2017-05-07', 17, 10, 2, 8, 'sunday ', 1, 0, 'NONE') ,('2017-05-08', '1396-02-18', '1438-08-11', '2017-05-08', 18, 11, 2, 8, 'monday ', 2, 0, 'NONE') ,('2017-05-09', '1396-02-19', '1438-08-12', '2017-05-09', 19, 12, 2, 8, 'tuesday ', 3, 0, 'NONE') ,('2017-05-10', '1396-02-20', '1438-08-13', '2017-05-10', 20, 13, 2, 8, 'wednesday', 4, 0, 'NONE') ,('2017-05-11', '13
WITH A as (SELECT rowNumberInAllBlocks() R,addDays(toDate('2021-05-18'), R) TVV from numbers(5)),
B as (SELECT rowNumberInAllBlocks() R,toDateTime(NULL) TVV from numbers(1))
SELECT
joinGet('DATE_INFO_DICT', 'SHAMSI', toDate(A.TVV) ) TV1,
substr(TV1, 3, 8) || ' : ' || toString(1) TV_CHAR_1
2021-10-03 05:01:51 +00:00
from A LEFT JOIN B USING (R)
ORDER BY TV1;
2021-06-13 22:58:06 +00:00
--query run success in 215ms
WITH A as (SELECT rowNumberInAllBlocks() R,addDays(toDate('2021-05-18'), R) TVV from numbers(5)),
B as (SELECT rowNumberInAllBlocks() R,toDateTime(NULL) TVV from numbers(1))
SELECT
joinGetOrNull('DATE_INFO_DICT', 'SHAMSI', toDate(A.TVV) ) TV1,
substr(TV1, 3, 8) || ' : ' || toString(1) TV_CHAR_1
2021-10-03 05:01:51 +00:00
from A LEFT JOIN B USING (R)
ORDER BY TV1;
2021-06-13 22:58:06 +00:00
--query not run success !!!!
DROP TABLE DATE_INFO_DICT;