Skip to content

Commit 64dc5eb

Browse files
committed
Fix parquet reader
1 parent 51a05a1 commit 64dc5eb

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

velox/connectors/hive/HiveDataSource.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -651,10 +651,19 @@ void HiveDataSource::addSplit(std::shared_ptr<ConnectorSplit> split) {
651651
} else {
652652
auto fileTypeIdx = fileType->getChildIdxIfExists(fieldName);
653653
if (!fileTypeIdx.has_value()) {
654-
// Column is missing. Most likely due to schema evolution.
655-
VELOX_CHECK(readerOpts_.getFileSchema());
656-
setNullConstantValue(
657-
childSpec, readerOpts_.getFileSchema()->findChild(fieldName));
654+
// If field name exists in the user-specified output type,
655+
// set the column as null constant.
656+
// Related PR: https://github.com/facebookincubator/velox/pull/6427.
657+
auto outputTypeIdx = readerOutputType_->getChildIdxIfExists(fieldName);
658+
if (outputTypeIdx.has_value()) {
659+
setNullConstantValue(
660+
childSpec, readerOutputType_->childAt(outputTypeIdx.value()));
661+
} else {
662+
// Column is missing. Most likely due to schema evolution.
663+
VELOX_CHECK(readerOpts_.getFileSchema());
664+
setNullConstantValue(
665+
childSpec, readerOpts_.getFileSchema()->findChild(fieldName));
666+
}
658667
} else {
659668
// Column no longer missing, reset constant value set on the spec.
660669
childSpec->setConstantValue(nullptr);

velox/dwio/common/SelectiveRepeatedColumnReader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,12 @@ void SelectiveMapColumnReader::getValues(RowSet rows, VectorPtr* result) {
282282
"SelectiveMapColumnReader::getValues");
283283
if (!nestedRows_.empty()) {
284284
keyReader_->getValues(nestedRows_, &keys);
285-
prepareStructResult(requestedType_->type()->childAt(1), &values);
285+
prepareStructResult(result->get()->type()->childAt(1), &values);
286286
elementReader_->getValues(nestedRows_, &values);
287287
}
288288
*result = std::make_shared<MapVector>(
289289
&memoryPool_,
290-
requestedType_->type(),
290+
result->get()->type(),
291291
anyNulls_ ? resultNulls_ : nullptr,
292292
rows.size(),
293293
offsets_,

0 commit comments

Comments
 (0)