Skip to content

Commit

Permalink
fix: Align TimestampUnit and TimestampPrecision in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zuyu committed Nov 30, 2024
1 parent ac5c15e commit e1e50f9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion velox/dwio/parquet/tests/reader/ParquetTableScanTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@ class ParquetTableScanTest : public HiveConnectorTestBase {
rowType, subfieldFilters, remainingFilter, nullptr, assignments)
.planNode();

assertQuery(plan, splits_, sql);
AssertQueryBuilder(plan, duckDbQueryRunner_)
.connectorSessionProperty(
kHiveConnectorId,
HiveConfig::kReadTimestampUnitSession,
std::to_string(static_cast<int>(timestampPrecision_)))
.splits(splits_)
.assertResults(sql);
}

void assertSelectWithAgg(
Expand Down Expand Up @@ -211,6 +217,11 @@ class ParquetTableScanTest : public HiveConnectorTestBase {
rootPool_->addAggregateChild("ParquetTableScanTest.Writer");
options.memoryPool = childPool.get();

if (options.parquetWriteTimestampUnit) {
timestampPrecision_ =
static_cast<TimestampPrecision>(*options.parquetWriteTimestampUnit);
}

auto writer = std::make_unique<Writer>(
std::move(sink), options, asRowType(data[0]->type()));

Expand Down Expand Up @@ -298,6 +309,7 @@ class ParquetTableScanTest : public HiveConnectorTestBase {

RowTypePtr rowType_;
std::vector<std::shared_ptr<connector::ConnectorSplit>> splits_;
TimestampPrecision timestampPrecision_ = TimestampPrecision::kMilliseconds;
};

TEST_F(ParquetTableScanTest, basic) {
Expand Down Expand Up @@ -820,13 +832,15 @@ TEST_F(ParquetTableScanTest, timestampInt96Dictionary) {
WriterOptions options;
options.writeInt96AsTimestamp = true;
options.enableDictionary = true;
options.parquetWriteTimestampUnit = TimestampUnit::kMilli;
testInt96TimestampRead(options);
}

TEST_F(ParquetTableScanTest, timestampInt96Plain) {
WriterOptions options;
options.writeInt96AsTimestamp = true;
options.enableDictionary = false;
options.parquetWriteTimestampUnit = TimestampUnit::kMilli;
testInt96TimestampRead(options);
}

Expand Down

0 comments on commit e1e50f9

Please sign in to comment.