You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by dh...@apache.org on 2023/07/27 15:08:25 UTC
[arrow-datafusion] 01/01: Change empty projection to not add an extra column
This is an automated email from the ASF dual-hosted git repository.
dheres pushed a commit to branch empty_projection
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
commit 69eba492244574316138ea1fe16ce37d6a297466
Author: Daniƫl Heres <da...@coralogix.com>
AuthorDate: Thu Jul 27 17:08:12 2023 +0200
Change empty projection to not add an extra column
---
datafusion/optimizer/src/push_down_projection.rs | 25 ++++++++----------------
1 file changed, 8 insertions(+), 17 deletions(-)
diff --git a/datafusion/optimizer/src/push_down_projection.rs b/datafusion/optimizer/src/push_down_projection.rs
index eb9ae3c981..4545234864 100644
--- a/datafusion/optimizer/src/push_down_projection.rs
+++ b/datafusion/optimizer/src/push_down_projection.rs
@@ -495,23 +495,14 @@ fn push_down_scan(
.filter_map(ArrowResult::ok)
.collect();
- if projection.is_empty() {
- if has_projection && !schema.fields().is_empty() {
- // Ensure that we are reading at least one column from the table in case the query
- // does not reference any columns directly such as "SELECT COUNT(1) FROM table",
- // except when the table is empty (no column)
- projection.insert(0);
- } else {
- // for table scan without projection, we default to return all columns
- projection = scan
- .source
- .schema()
- .fields()
- .iter()
- .enumerate()
- .map(|(i, _)| i)
- .collect::<BTreeSet<usize>>();
- }
+ if projection.is_empty() && !has_projection {
+ // for table scan without projection, we default to return all columns
+ projection = schema
+ .fields()
+ .iter()
+ .enumerate()
+ .map(|(i, _)| i)
+ .collect::<BTreeSet<usize>>();
}
// Building new projection from BTreeSet