-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Project result top level columns according to scan spec for non-selec…
…tive readers (#5726) Summary: Pull Request resolved: #5726 For non-selective readers, there is no filters in scan spec, but we still need to handle the projections for top level columns specified there. Add an helper function to achieve that and use it to fix `TextReader` (non-OSS). Reviewed By: zacw7 Differential Revision: D47597154 fbshipit-source-id: 1aea75c02e6ec1e33db2b148ec0062cc2039042b
- Loading branch information
1 parent
fc5f3d3
commit 5392abb
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "velox/dwio/common/Reader.h" | ||
|
||
namespace facebook::velox::dwio::common { | ||
|
||
VectorPtr RowReader::projectColumns( | ||
const VectorPtr& input, | ||
const velox::common::ScanSpec& spec) { | ||
auto* inputRow = input->as<RowVector>(); | ||
VELOX_CHECK_NOT_NULL(inputRow); | ||
auto& inputRowType = input->type()->asRow(); | ||
column_index_t numColumns = 0; | ||
for (auto& childSpec : spec.children()) { | ||
numColumns = std::max(numColumns, childSpec->channel() + 1); | ||
} | ||
std::vector<std::string> names(numColumns); | ||
std::vector<TypePtr> types(numColumns); | ||
std::vector<VectorPtr> children(numColumns); | ||
for (auto& childSpec : spec.children()) { | ||
if (!childSpec->projectOut()) { | ||
continue; | ||
} | ||
auto i = childSpec->channel(); | ||
names[i] = childSpec->fieldName(); | ||
if (childSpec->isConstant()) { | ||
children[i] = BaseVector::wrapInConstant( | ||
input->size(), 0, childSpec->constantValue()); | ||
} else { | ||
children[i] = | ||
inputRow->childAt(inputRowType.getChildIdx(childSpec->fieldName())); | ||
} | ||
types[i] = children[i]->type(); | ||
} | ||
return std::make_shared<RowVector>( | ||
input->pool(), | ||
ROW(std::move(names), std::move(types)), | ||
nullptr, | ||
input->size(), | ||
std::move(children)); | ||
} | ||
|
||
} // namespace facebook::velox::dwio::common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters