Skip to content

Commit

Permalink
Generate empty column at placeholder exec (#8553)
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafasrepo authored Dec 15, 2023
1 parent b276d47 commit 28e7f60
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 4 additions & 3 deletions datafusion/physical-plan/src/placeholder_row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use crate::{memory::MemoryStream, DisplayFormatType, ExecutionPlan, Partitioning
use arrow::array::{ArrayRef, NullArray};
use arrow::datatypes::{DataType, Field, Fields, Schema, SchemaRef};
use arrow::record_batch::RecordBatch;
use arrow_array::RecordBatchOptions;
use datafusion_common::{internal_err, DataFusionError, Result};
use datafusion_execution::TaskContext;

Expand Down Expand Up @@ -59,9 +60,7 @@ impl PlaceholderRowExec {
fn data(&self) -> Result<Vec<RecordBatch>> {
Ok({
let n_field = self.schema.fields.len();
// hack for https://github.com/apache/arrow-datafusion/pull/3242
let n_field = if n_field == 0 { 1 } else { n_field };
vec![RecordBatch::try_new(
vec![RecordBatch::try_new_with_options(
Arc::new(Schema::new(
(0..n_field)
.map(|i| {
Expand All @@ -75,6 +74,8 @@ impl PlaceholderRowExec {
ret
})
.collect(),
// Even if column number is empty we can generate single row.
&RecordBatchOptions::new().with_row_count(Some(1)),
)?]
})
}
Expand Down
6 changes: 6 additions & 0 deletions datafusion/sqllogictest/test_files/window.slt
Original file line number Diff line number Diff line change
Expand Up @@ -3793,3 +3793,9 @@ select a,
----
1 1
2 1

query I
select rank() over (order by 1) rnk from (select 1 a union all select 2 a) x
----
1
1

0 comments on commit 28e7f60

Please sign in to comment.