Skip to content

Commit

Permalink
Fix ORC related failed UT
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxu14 authored and zhouyuan committed Nov 17, 2023
1 parent bf8f183 commit d0c22c7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions velox/connectors/hive/HiveConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ std::unique_ptr<core::PartitionFunction> HivePartitionFunctionSpec::create(
void HiveConnectorFactory::initialize() {
static bool once = []() {
dwio::common::registerFileSinks();
dwrf::registerOrcReaderFactory();
dwrf::registerDwrfReaderFactory();
dwrf::registerDwrfWriterFactory();
// Meta's buck build system needs this check.
Expand Down
4 changes: 2 additions & 2 deletions velox/dwio/dwrf/common/FileMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ class FooterWrapper : public ProtoWrapperBase {

// TODO: ORC has not supported column statistics yet
int statisticsSize() const {
return format_ == DwrfFormat::kDwrf ? dwrfPtr()->statistics_size() : 0;
return format_ == DwrfFormat::kDwrf ? dwrfPtr()->statistics_size()
: orcPtr()->statistics_size();
}

const ::google::protobuf::RepeatedPtrField<
Expand All @@ -438,7 +439,6 @@ class FooterWrapper : public ProtoWrapperBase {

const ::facebook::velox::dwrf::proto::ColumnStatistics& statistics(
int index) const {
VELOX_CHECK_EQ(format_, DwrfFormat::kDwrf);
return dwrfPtr()->statistics(index);
}

Expand Down
8 changes: 8 additions & 0 deletions velox/dwio/dwrf/reader/DwrfReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1106,4 +1106,12 @@ void unregisterDwrfReaderFactory() {
dwio::common::unregisterReaderFactory(dwio::common::FileFormat::DWRF);
}

void registerOrcReaderFactory() {
dwio::common::registerReaderFactory(std::make_shared<OrcReaderFactory>());
}

void unregisterOrcReaderFactory() {
dwio::common::unregisterReaderFactory(dwio::common::FileFormat::ORC);
}

} // namespace facebook::velox::dwrf
15 changes: 15 additions & 0 deletions velox/dwio/dwrf/reader/DwrfReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,23 @@ class DwrfReaderFactory : public dwio::common::ReaderFactory {
}
};

class OrcReaderFactory : public dwio::common::ReaderFactory {
public:
OrcReaderFactory() : ReaderFactory(dwio::common::FileFormat::ORC) {}

std::unique_ptr<dwio::common::Reader> createReader(
std::unique_ptr<dwio::common::BufferedInput> input,
const dwio::common::ReaderOptions& options) override {
return DwrfReader::create(std::move(input), options);
}
};

void registerDwrfReaderFactory();

void unregisterDwrfReaderFactory();

void registerOrcReaderFactory();

void unregisterOrcReaderFactory();

} // namespace facebook::velox::dwrf

0 comments on commit d0c22c7

Please sign in to comment.