Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MINOR]: Generate empty column at placeholder exec #8553

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

&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
Loading