Skip to content

Commit 5e3b051

Browse files
committed
add test case from #1335
Signed-off-by: Mikhail Filimonov <mfilimonov@altinity.com>
1 parent c8bc98a commit 5e3b051

3 files changed

Lines changed: 88 additions & 1 deletion

File tree

src/Analyzer/createUniqueAliasesIfNecessary.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ void createUniqueAliasesIfNecessary(QueryTreeNodePtr & node, const ContextPtr &
226226
* It's required to create a valid AST for distributed query.
227227
*/
228228
CreateUniqueArrayJoinAliasesVisitor(context).visit(node);
229-
230229
}
231230

232231
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
manual column definition with wrong alias type
2+
1 100 1970-01-01 99
3+
2 200 1970-01-01 199
4+
3 300 1970-01-01 299
5+
4 400 1970-01-01 399
6+
5 500 1970-01-01 499
7+
6 600 1970-01-01 599
8+
auto column definition works
9+
1 100 1970-01-01 99
10+
2 200 1970-01-01 199
11+
3 300 1970-01-01 299
12+
4 400 1970-01-01 399
13+
5 500 1970-01-01 499
14+
6 600 1970-01-01 599
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
SET allow_experimental_hybrid_table = 1,
2+
enable_analyzer = 1,
3+
enable_alias_marker = 1,
4+
prefer_localhost_replica = 0;
5+
6+
DROP TABLE IF EXISTS test_hybrid_issue_1335;
7+
DROP TABLE IF EXISTS test_hybrid_issue_1335_without_col_def;
8+
DROP TABLE IF EXISTS test_hybrid_issue_1335_left;
9+
DROP TABLE IF EXISTS test_hybrid_issue_1335_right;
10+
11+
CREATE TABLE test_hybrid_issue_1335_left
12+
(
13+
id Int32,
14+
value Int32,
15+
date_col Date,
16+
value_minus ALIAS value - 1
17+
)
18+
ENGINE = MergeTree
19+
PARTITION BY toYYYYMM(date_col)
20+
ORDER BY (date_col, id);
21+
22+
CREATE TABLE test_hybrid_issue_1335_right
23+
(
24+
id Int32,
25+
value Int32,
26+
date_col Date,
27+
value_minus ALIAS value - 1
28+
)
29+
ENGINE = MergeTree
30+
PARTITION BY toYYYYMM(date_col)
31+
ORDER BY (date_col, id);
32+
33+
INSERT INTO test_hybrid_issue_1335_left VALUES
34+
(1, 100, toDate('1970-01-01')),
35+
(2, 200, toDate('1970-01-01')),
36+
(3, 300, toDate('1970-01-01'));
37+
38+
INSERT INTO test_hybrid_issue_1335_right VALUES
39+
(4, 400, toDate('1970-01-01')),
40+
(5, 500, toDate('1970-01-01')),
41+
(6, 600, toDate('1970-01-01'));
42+
43+
SELECT 'manual column definition with wrong alias type';
44+
CREATE TABLE test_hybrid_issue_1335
45+
(
46+
id Int32,
47+
value Int32,
48+
date_col Date,
49+
value_minus Int32
50+
)
51+
ENGINE = Hybrid(
52+
remote('127.0.0.1:9000', currentDatabase(), 'test_hybrid_issue_1335_left'), id < 4,
53+
remote('127.0.0.1:9000', currentDatabase(), 'test_hybrid_issue_1335_right'), id >= 4
54+
);
55+
56+
SELECT id, value, date_col, value_minus
57+
FROM test_hybrid_issue_1335
58+
ORDER BY id;
59+
60+
SELECT 'auto column definition works';
61+
CREATE TABLE test_hybrid_issue_1335_without_col_def
62+
ENGINE = Hybrid(
63+
remote('127.0.0.1:9000', currentDatabase(), 'test_hybrid_issue_1335_left'), id < 4,
64+
remote('127.0.0.1:9000', currentDatabase(), 'test_hybrid_issue_1335_right'), id >= 4
65+
);
66+
67+
SELECT id, value, date_col, value_minus
68+
FROM test_hybrid_issue_1335_without_col_def
69+
ORDER BY id;
70+
71+
DROP TABLE test_hybrid_issue_1335;
72+
DROP TABLE test_hybrid_issue_1335_without_col_def;
73+
DROP TABLE test_hybrid_issue_1335_left;
74+
DROP TABLE test_hybrid_issue_1335_right;

0 commit comments

Comments
 (0)