Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
majetideepak committed May 22, 2024
1 parent 35199e3 commit ee0e977
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion velox/dwio/parquet/reader/ParquetReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ TypePtr ReaderBase::convertType(
case thrift::Type::type::INT64:
return BIGINT();
case thrift::Type::type::INT96:
return DOUBLE(); // TODO: Lose precision
return TIMESTAMP(); // INT96 only maps to a timestamp
case thrift::Type::type::FLOAT:
return REAL();
case thrift::Type::type::DOUBLE:
Expand Down
Binary file not shown.
29 changes: 29 additions & 0 deletions velox/dwio/parquet/tests/reader/ParquetReaderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1128,3 +1128,32 @@ TEST_F(ParquetReaderTest, testEnumType) {

assertReadWithReaderAndExpected(fileSchema, *rowReader, expected, *leafPool_);
}

TEST_F(ParquetReaderTest, parseVarbinaryFromFLBA) {
const std::string filename("varbinary_flba.parquet");
const std::string sample(getExampleFilePath(filename));

facebook::velox::dwio::common::ReaderOptions readerOptions{leafPool_.get()};
auto reader = createReader(sample, readerOptions);

auto type = reader->typeWithId();
EXPECT_EQ(type->size(), 8ULL);
auto col8 =
std::static_pointer_cast<const ParquetTypeWithId>(type->childAt(6));
EXPECT_EQ(col8->name_, "flba_field");
EXPECT_EQ(col8->parquetType_, thrift::Type::FIXED_LEN_BYTE_ARRAY);

auto selectedType = ROW({"flba_field"}, {VARBINARY()});
auto rowReaderOpts = getReaderOpts(selectedType);
rowReaderOpts.setScanSpec(makeScanSpec(selectedType));
auto rowReader = reader->createRowReader(rowReaderOpts);

auto expected = std::string(1024, '*');

VectorPtr result = BaseVector::create(selectedType, 0, &(*leafPool_));
rowReader->next(1, result);
EXPECT_EQ(
expected,
result->as<RowVector>()->childAt(0)->asFlatVector<StringView>()->valueAt(
0));
}

0 comments on commit ee0e977

Please sign in to comment.