Skip to content

Commit 6dd5ed7

Browse files
chenxu14zhztheplayer
authored andcommitted
Fix ORC related failed UT (#417)
1 parent 007ffe9 commit 6dd5ed7

File tree

7 files changed

+43
-3
lines changed

7 files changed

+43
-3
lines changed

velox/connectors/hive/HiveConnector.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ std::unique_ptr<core::PartitionFunction> HivePartitionFunctionSpec::create(
140140
void HiveConnectorFactory::initialize() {
141141
static bool once = []() {
142142
dwio::common::registerFileSinks();
143+
dwrf::registerOrcReaderFactory();
143144
dwrf::registerDwrfReaderFactory();
144145
dwrf::registerDwrfWriterFactory();
145146
// Meta's buck build system needs this check.

velox/dwio/dwrf/common/FileMetadata.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,8 @@ class FooterWrapper : public ProtoWrapperBase {
426426

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

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

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

velox/dwio/dwrf/reader/DwrfReader.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,4 +1108,12 @@ void unregisterDwrfReaderFactory() {
11081108
dwio::common::unregisterReaderFactory(dwio::common::FileFormat::DWRF);
11091109
}
11101110

1111+
void registerOrcReaderFactory() {
1112+
dwio::common::registerReaderFactory(std::make_shared<OrcReaderFactory>());
1113+
}
1114+
1115+
void unregisterOrcReaderFactory() {
1116+
dwio::common::unregisterReaderFactory(dwio::common::FileFormat::ORC);
1117+
}
1118+
11111119
} // namespace facebook::velox::dwrf

velox/dwio/dwrf/reader/DwrfReader.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,23 @@ class DwrfReaderFactory : public dwio::common::ReaderFactory {
365365
}
366366
};
367367

368+
class OrcReaderFactory : public dwio::common::ReaderFactory {
369+
public:
370+
OrcReaderFactory() : ReaderFactory(dwio::common::FileFormat::ORC) {}
371+
372+
std::unique_ptr<dwio::common::Reader> createReader(
373+
std::unique_ptr<dwio::common::BufferedInput> input,
374+
const dwio::common::ReaderOptions& options) override {
375+
return DwrfReader::create(std::move(input), options);
376+
}
377+
};
378+
368379
void registerDwrfReaderFactory();
369380

370381
void unregisterDwrfReaderFactory();
371382

383+
void registerOrcReaderFactory();
384+
385+
void unregisterOrcReaderFactory();
386+
372387
} // namespace facebook::velox::dwrf

velox/dwio/dwrf/reader/SelectiveDecimalColumnReader.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ class SelectiveDecimalColumnReader : public SelectiveColumnReader {
4040

4141
void getValues(RowSet rows, VectorPtr* result) override;
4242

43+
bool hasBulkPath() const override {
44+
return false;
45+
}
46+
4347
private:
4448
template <bool kDense>
4549
void readHelper(RowSet rows);

velox/dwio/dwrf/reader/SelectiveIntegerDirectColumnReader.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ class SelectiveIntegerDirectColumnReader
6363
}
6464

6565
bool hasBulkPath() const override {
66-
return true;
66+
if (format == velox::dwrf::DwrfFormat::kOrc) {
67+
return false; // RLEv2 does't support FastPath yet
68+
} else {
69+
return true;
70+
}
6771
}
6872

6973
void seekToRowGroup(uint32_t index) override {

velox/dwio/dwrf/reader/SelectiveStringDictionaryColumnReader.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ class SelectiveStringDictionaryColumnReader
5353

5454
uint64_t skip(uint64_t numValues) override;
5555

56+
bool hasBulkPath() const override {
57+
if (version_ == velox::dwrf::RleVersion_1) {
58+
return true;
59+
} else {
60+
return false; // RLEv2 does't support FastPath yet
61+
}
62+
}
63+
5664
void read(vector_size_t offset, RowSet rows, const uint64_t* incomingNulls)
5765
override;
5866

0 commit comments

Comments
 (0)