Skip to content

Commit 5b10d09

Browse files
committed
Add plain test
1 parent 5f9bd7d commit 5b10d09

File tree

6 files changed

+72
-93
lines changed

6 files changed

+72
-93
lines changed

velox/dwio/common/IntDecoder.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,8 @@ inline T IntDecoder<isSigned>::readInt() {
444444
if (numBytes == 12) {
445445
VELOX_DCHECK(!useVInts, "Int96 should not be VInt encoded.");
446446
return readInt96();
447-
} else {
448-
VELOX_NYI();
449447
}
448+
VELOX_NYI();
450449
}
451450
return readLongLE();
452451
}
Binary file not shown.
Binary file not shown.
Binary file not shown.

velox/dwio/parquet/tests/reader/ParquetTableScanTest.cpp

Lines changed: 71 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,72 @@ class ParquetTableScanTest : public HiveConnectorTestBase {
221221
writer->close();
222222
}
223223

224+
void testInt96TimestampRead(const std::string& fileName) {
225+
// Timestamp-int96.parquet holds one column (t: TIMESTAMP) and
226+
// 10 rows in one row group. Data is in SNAPPY compressed format.
227+
// The values are:
228+
// |t |
229+
// +-------------------+
230+
// |2015-06-01 19:34:56|
231+
// |2015-06-02 19:34:56|
232+
// |2001-02-03 03:34:06|
233+
// |1998-03-01 08:01:06|
234+
// |2022-12-23 03:56:01|
235+
// |1980-01-24 00:23:07|
236+
// |1999-12-08 13:39:26|
237+
// |2023-04-21 09:09:34|
238+
// |2000-09-12 22:36:29|
239+
// |2007-12-12 04:27:56|
240+
// +-------------------+
241+
auto vector = makeFlatVector<Timestamp>(
242+
{Timestamp(1433187296, 0),
243+
Timestamp(1433273696, 0),
244+
Timestamp(981171246, 0),
245+
Timestamp(888739266, 0),
246+
Timestamp(1671767761, 0),
247+
Timestamp(317521387, 0),
248+
Timestamp(944660366, 0),
249+
Timestamp(1682068174, 0),
250+
Timestamp(968798189, 0),
251+
Timestamp(1197433676, 0)});
252+
253+
loadData(
254+
getExampleFilePath(fileName),
255+
ROW({"t"}, {TIMESTAMP()}),
256+
makeRowVector(
257+
{"t"},
258+
{
259+
vector,
260+
}));
261+
262+
assertSelectWithFilter({"t"}, {}, "", "SELECT t from tmp");
263+
assertSelectWithFilter(
264+
{"t"},
265+
{},
266+
"t < TIMESTAMP '2000-09-12 22:36:29'",
267+
"SELECT t from tmp where t < TIMESTAMP '2000-09-12 22:36:29'");
268+
assertSelectWithFilter(
269+
{"t"},
270+
{},
271+
"t <= TIMESTAMP '2000-09-12 22:36:29'",
272+
"SELECT t from tmp where t <= TIMESTAMP '2000-09-12 22:36:29'");
273+
assertSelectWithFilter(
274+
{"t"},
275+
{},
276+
"t > TIMESTAMP '1980-01-24 00:23:07'",
277+
"SELECT t from tmp where t > TIMESTAMP '1980-01-24 00:23:07'");
278+
assertSelectWithFilter(
279+
{"t"},
280+
{},
281+
"t >= TIMESTAMP '1980-01-24 00:23:07'",
282+
"SELECT t from tmp where t >= TIMESTAMP '1980-01-24 00:23:07'");
283+
assertSelectWithFilter(
284+
{"t"},
285+
{},
286+
"t == TIMESTAMP '2022-12-23 03:56:01'",
287+
"SELECT t from tmp where t == TIMESTAMP '2022-12-23 03:56:01'");
288+
}
289+
224290
private:
225291
RowTypePtr getRowType(std::vector<std::string>&& outputColumnNames) const {
226292
std::vector<TypePtr> types;
@@ -719,70 +785,12 @@ TEST_F(ParquetTableScanTest, sessionTimezone) {
719785
assertSelectWithTimezone({"a"}, "SELECT a FROM tmp", "Asia/Shanghai");
720786
}
721787

722-
TEST_F(ParquetTableScanTest, timestampFilter) {
723-
// Timestamp-int96.parquet holds one column (t: TIMESTAMP) and
724-
// 10 rows in one row group. Data is in SNAPPY compressed format.
725-
// The values are:
726-
// |t |
727-
// +-------------------+
728-
// |2015-06-01 19:34:56|
729-
// |2015-06-02 19:34:56|
730-
// |2001-02-03 03:34:06|
731-
// |1998-03-01 08:01:06|
732-
// |2022-12-23 03:56:01|
733-
// |1980-01-24 00:23:07|
734-
// |1999-12-08 13:39:26|
735-
// |2023-04-21 09:09:34|
736-
// |2000-09-12 22:36:29|
737-
// |2007-12-12 04:27:56|
738-
// +-------------------+
739-
auto vector = makeFlatVector<Timestamp>(
740-
{Timestamp(1433187296, 0),
741-
Timestamp(1433273696, 0),
742-
Timestamp(981171246, 0),
743-
Timestamp(888739266, 0),
744-
Timestamp(1671767761, 0),
745-
Timestamp(317521387, 0),
746-
Timestamp(944660366, 0),
747-
Timestamp(1682068174, 0),
748-
Timestamp(968798189, 0),
749-
Timestamp(1197433676, 0)});
750-
751-
loadData(
752-
getExampleFilePath("timestamp_int96.parquet"),
753-
ROW({"t"}, {TIMESTAMP()}),
754-
makeRowVector(
755-
{"t"},
756-
{
757-
vector,
758-
}));
788+
TEST_F(ParquetTableScanTest, timestampInt96Dictionary) {
789+
testInt96TimestampRead("timestamp_int96_dictionary.parquet");
790+
}
759791

760-
assertSelectWithFilter({"t"}, {}, "", "SELECT t from tmp");
761-
assertSelectWithFilter(
762-
{"t"},
763-
{},
764-
"t < TIMESTAMP '2000-09-12 22:36:29'",
765-
"SELECT t from tmp where t < TIMESTAMP '2000-09-12 22:36:29'");
766-
assertSelectWithFilter(
767-
{"t"},
768-
{},
769-
"t <= TIMESTAMP '2000-09-12 22:36:29'",
770-
"SELECT t from tmp where t <= TIMESTAMP '2000-09-12 22:36:29'");
771-
assertSelectWithFilter(
772-
{"t"},
773-
{},
774-
"t > TIMESTAMP '1980-01-24 00:23:07'",
775-
"SELECT t from tmp where t > TIMESTAMP '1980-01-24 00:23:07'");
776-
assertSelectWithFilter(
777-
{"t"},
778-
{},
779-
"t >= TIMESTAMP '1980-01-24 00:23:07'",
780-
"SELECT t from tmp where t >= TIMESTAMP '1980-01-24 00:23:07'");
781-
assertSelectWithFilter(
782-
{"t"},
783-
{},
784-
"t == TIMESTAMP '2022-12-23 03:56:01'",
785-
"SELECT t from tmp where t == TIMESTAMP '2022-12-23 03:56:01'");
792+
TEST_F(ParquetTableScanTest, timestampInt96Plain) {
793+
testInt96TimestampRead("timestamp_int96_plain.parquet");
786794
}
787795

788796
TEST_F(ParquetTableScanTest, timestampPrecisionMicrosecond) {
@@ -836,34 +844,6 @@ TEST_F(ParquetTableScanTest, timestampPrecisionMicrosecond) {
836844
assertEqualResults({expected}, result.second);
837845
}
838846

839-
840-
TEST_F(ParquetTableScanTest, timestampINT96) {
841-
auto a = makeFlatVector<Timestamp>({Timestamp(1, 0), Timestamp(2, 0)});
842-
auto expected = makeRowVector({"time"}, {a});
843-
createDuckDbTable("expected", {expected});
844-
845-
auto vector = makeArrayVector<Timestamp>({{}});
846-
loadData(
847-
getExampleFilePath("timestamp_dict_int96.parquet"),
848-
ROW({"time"}, {TIMESTAMP()}),
849-
makeRowVector(
850-
{"time"},
851-
{
852-
vector,
853-
}));
854-
assertSelect({"time"}, "SELECT time from expected");
855-
856-
loadData(
857-
getExampleFilePath("timestamp_plain_int96.parquet"),
858-
ROW({"time"}, {TIMESTAMP()}),
859-
makeRowVector(
860-
{"time"},
861-
{
862-
vector,
863-
}));
864-
assertSelect({"time"}, "SELECT time from expected");
865-
}
866-
867847
int main(int argc, char** argv) {
868848
testing::InitGoogleTest(&argc, argv);
869849
folly::Init init{&argc, &argv, false};

0 commit comments

Comments
 (0)