From d62423c07065497f4fce673c60376c0972c2c117 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lisen=20=E6=9D=A8?=
Date: Wed, 22 May 2024 11:15:08 +0800
Subject: [PATCH] support append-only left all join append-only
---
src/Interpreters/Streaming/HashJoin.cpp | 1 +
.../tests/gtest_streaming_hash_join.cpp | 50 +++++++++++++++++++
2 files changed, 51 insertions(+)
diff --git a/src/Interpreters/Streaming/HashJoin.cpp b/src/Interpreters/Streaming/HashJoin.cpp
index 9d69651f7e..f1ed8aa3b1 100644
--- a/src/Interpreters/Streaming/HashJoin.cpp
+++ b/src/Interpreters/Streaming/HashJoin.cpp
@@ -788,6 +788,7 @@ const HashJoin::SupportMatrix HashJoin::support_matrix = {
{{StorageSemantic::Append, JoinKind::Left, JoinStrictness::All, StorageSemantic::ChangelogKV}, true},
{{StorageSemantic::Append, JoinKind::Left, JoinStrictness::All, StorageSemantic::VersionedKV}, true},
{{StorageSemantic::Append, JoinKind::Left, JoinStrictness::All, StorageSemantic::Changelog}, true},
+ {{StorageSemantic::Append, JoinKind::Left, JoinStrictness::All, StorageSemantic::Append}, true},
{{StorageSemantic::Append, JoinKind::Left, JoinStrictness::Asof, StorageSemantic::Append}, true},
{{StorageSemantic::Append, JoinKind::Left, JoinStrictness::Asof, StorageSemantic::VersionedKV}, true},
diff --git a/src/Interpreters/Streaming/tests/gtest_streaming_hash_join.cpp b/src/Interpreters/Streaming/tests/gtest_streaming_hash_join.cpp
index 6191e1b6c4..01128a2410 100644
--- a/src/Interpreters/Streaming/tests/gtest_streaming_hash_join.cpp
+++ b/src/Interpreters/Streaming/tests/gtest_streaming_hash_join.cpp
@@ -826,6 +826,56 @@ TEST(StreamingHashJoin, SimpleJoinTests)
}
}
+TEST(StreamingHashJoin, AppendLeftAllJoinAppend)
+{
+ auto context = getContext().context;
+ Block left_header = prepareBlock(/*types*/ {"int", "datetime64(3, 'UTC')"}, /*no data*/ "", context);
+ Block right_header = prepareBlock(/*types*/ {"int", "datetime64(3, 'UTC')"}, /*no data*/ "", context);
+
+ /// stream(t1) left all join stream(t2) on t1.col_1 = t2.col_1
+ commonTest(
+ "left",
+ "all",
+ /*on_clause*/ "t1.col_1 = t2.col_1",
+ left_header,
+ Streaming::StorageSemantic::Append,
+ /*left_primary_key_column_indexes*/ std::nullopt,
+ right_header,
+ Streaming::StorageSemantic::Append,
+ /*right_primary_key_column_indexes*/ std::nullopt,
+ /*to_join_steps*/
+ {
+ {
+ /*to join pos*/ ToJoinStep::LEFT,
+ /*to join block*/ prepareBlockByHeader(left_header, "(1, '2023-1-1 00:00:00')", context),
+ /*expected join results*/
+ ExpectedJoinResults{
+ /// output header: col_1, col_2, t2.col_2
+ .values = "(1, '2023-1-1 00:00:00', '1970-1-1 00:00:00')",
+ },
+ },
+ {
+ /*to join pos*/ ToJoinStep::RIGHT,
+ /*to join block*/ prepareBlockByHeader(right_header, "(1, '2023-1-1 00:00:01')", context),
+ /*expected join results*/
+ ExpectedJoinResults{
+ /// output header: col_1, col_2, t2.col_2
+ .values = "(1, '2023-1-1 00:00:00', '2023-1-1 00:00:01')",
+ },
+ },
+ {
+ /*to join pos*/ ToJoinStep::LEFT,
+ /*to join block*/ prepareBlockByHeader(left_header, "(1, '2023-1-1 00:00:02')", context),
+ /*expected join results*/
+ ExpectedJoinResults{
+ /// output header: col_1, col_2, t2.col_2
+ .values = "(1, '2023-1-1 00:00:02', '2023-1-1 00:00:01')",
+ },
+ },
+ },
+ context);
+}
+
TEST(StreamingHashJoin, AppendLeftAsofJoinAppend)
{
auto context = getContext().context;