mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
add inner asof join with tests
This commit is contained in:
parent
817a9244c0
commit
e7a10b8a3e
@ -273,12 +273,12 @@ void Join::setSampleBlock(const Block & block)
|
||||
|
||||
if (strictness == ASTTableJoin::Strictness::Asof)
|
||||
{
|
||||
if (kind != ASTTableJoin::Kind::Left)
|
||||
throw Exception("ASOF only supports LEFT as base join", ErrorCodes::NOT_IMPLEMENTED);
|
||||
if (kind != ASTTableJoin::Kind::Left and kind != ASTTableJoin::Kind::Inner)
|
||||
throw Exception("ASOF only supports LEFT and INNER as base joins", ErrorCodes::NOT_IMPLEMENTED);
|
||||
|
||||
if (key_columns.back()->sizeOfValueIfFixed() != sizeof(ASOFTimeType))
|
||||
{
|
||||
std::string msg = "ASOF join columns need to have size ";
|
||||
std::string msg = "ASOF join column needs to have size ";
|
||||
msg += std::to_string(sizeof(ASOFTimeType));
|
||||
throw Exception(msg, ErrorCodes::BAD_TYPE_OF_FIELD);
|
||||
}
|
||||
|
@ -13,3 +13,17 @@
|
||||
3 1970-01-01 00:00:03 3 0 0000-00-00 00:00:00 0
|
||||
3 1970-01-01 00:00:04 4 0 0000-00-00 00:00:00 0
|
||||
3 1970-01-01 00:00:05 5 0 0000-00-00 00:00:00 0
|
||||
1 1970-01-01 00:00:02 2 2 1970-01-01 00:00:02 1
|
||||
1 1970-01-01 00:00:03 3 2 1970-01-01 00:00:03 1
|
||||
1 1970-01-01 00:00:04 4 4 1970-01-01 00:00:04 1
|
||||
1 1970-01-01 00:00:05 5 4 1970-01-01 00:00:05 1
|
||||
2 1970-01-01 00:00:03 3 3 1970-01-01 00:00:03 2
|
||||
2 1970-01-01 00:00:04 4 3 1970-01-01 00:00:04 2
|
||||
2 1970-01-01 00:00:05 5 3 1970-01-01 00:00:05 2
|
||||
1 1970-01-01 00:00:02 2 2 1970-01-01 00:00:02 1
|
||||
1 1970-01-01 00:00:03 3 2 1970-01-01 00:00:03 1
|
||||
1 1970-01-01 00:00:04 4 4 1970-01-01 00:00:04 1
|
||||
1 1970-01-01 00:00:05 5 4 1970-01-01 00:00:05 1
|
||||
2 1970-01-01 00:00:03 3 3 1970-01-01 00:00:03 2
|
||||
2 1970-01-01 00:00:04 4 3 1970-01-01 00:00:04 2
|
||||
2 1970-01-01 00:00:05 5 3 1970-01-01 00:00:05 2
|
||||
|
@ -14,6 +14,9 @@ INSERT INTO B(k,t,b) VALUES (2,3,3);
|
||||
|
||||
SELECT A.k, toString(A.t, 'UTC'), A.a, B.b, toString(B.t, 'UTC'), B.k FROM A ASOF LEFT JOIN B USING(k,t) ORDER BY (A.k, A.t);
|
||||
|
||||
SELECT A.k, toString(A.t, 'UTC'), A.a, B.b, toString(B.t, 'UTC'), B.k FROM A ASOF INNER JOIN B ON A.k == B.k AND A.t == B.t ORDER BY (A.k, A.t);
|
||||
|
||||
SELECT A.k, toString(A.t, 'UTC'), A.a, B.b, toString(B.t, 'UTC'), B.k FROM A ASOF JOIN B USING(k,t) ORDER BY (A.k, A.t);
|
||||
|
||||
DROP TABLE A;
|
||||
DROP TABLE B;
|
||||
|
Loading…
Reference in New Issue
Block a user