Skip to content

Commit 7deb461

Browse files
committed
add type conversion
1 parent 79425f8 commit 7deb461

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Storages/StorageDistributed.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <Processors/QueryPlan/QueryPlan.h>
1010
#include <Processors/QueryPlan/SourceStepWithFilter.h>
1111
#include <Processors/QueryPlan/Optimizations/QueryPlanOptimizationSettings.h>
12+
#include <Processors/QueryPlan/ConvertingActions.h>
1213
#include <Interpreters/InterpreterSelectQueryAnalyzer.h>
1314
#include <Interpreters/InterpreterSelectWithUnionQuery.h>
1415
#include <IO/WriteBufferFromString.h>
@@ -1225,10 +1226,19 @@ void StorageDistributed::read(
12251226
plan_ptrs.push_back(std::make_unique<QueryPlan>(std::move(plan)));
12261227
}
12271228

1229+
// Get the main plan's header to use as the target for type conversion
1230+
Block main_header = plan_ptrs[0]->getCurrentHeader();
1231+
1232+
// Add type conversion for each additional plan to match the main plan's header
1233+
for (size_t i = 1; i < plan_ptrs.size(); ++i)
1234+
{
1235+
addConvertingActions(*plan_ptrs[i], main_header, false);
1236+
}
1237+
12281238
// Create a new query plan that unions all the results
12291239
QueryPlan union_plan;
12301240

1231-
// Get headers from all plans
1241+
// Get headers from all plans (after conversion)
12321242
std::vector<Block> headers;
12331243
headers.reserve(plan_ptrs.size());
12341244
for (const auto & plan_ptr : plan_ptrs)

0 commit comments

Comments
 (0)