@@ -284,6 +284,17 @@ const int8_t* ColumnFetcher::getAllTableColumnFragments(
284284 total_row_count += rows_in_frag;
285285 }
286286
287+ if (total_row_count == 0 ) {
288+ std::unique_ptr<ColumnarResults> merged_results (nullptr );
289+
290+ table_column = merged_results.get ();
291+ columnarized_scan_table_cache_.emplace (std::make_pair (table_id, col_id),
292+ std::move (merged_results));
293+
294+ return ColumnFetcher::transferColumnIfNeeded (
295+ table_column, 0 , memory_level, device_id, device_allocator);
296+ }
297+
287298 const auto type_width = col_info->type ->size ();
288299 auto write_ptr =
289300 executor_->row_set_mem_owner_ ->allocate (type_width * total_row_count);
@@ -300,17 +311,7 @@ const int8_t* ColumnFetcher::getAllTableColumnFragments(
300311 valid_fragments.push_back (frag_id);
301312 }
302313
303- if (write_ptrs.empty ()) {
304- std::unique_ptr<ColumnarResults> merged_results (nullptr );
305-
306- table_column = merged_results.get ();
307- columnarized_scan_table_cache_.emplace (std::make_pair (table_id, col_id),
308- std::move (merged_results));
309-
310- return ColumnFetcher::transferColumnIfNeeded (
311- table_column, 0 , memory_level, device_id, device_allocator);
312- }
313-
314+ CHECK (!write_ptrs.empty ());
314315 size_t valid_frag_count = valid_fragments.size ();
315316 tbb::parallel_for (
316317 tbb::blocked_range<size_t >(0 , valid_frag_count),
0 commit comments