Skip to content

Commit

Permalink
Fix timestamp unit
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE committed Mar 7, 2024
1 parent 8dca741 commit 01969b3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions velox/vector/arrow/Bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,13 @@ const char* exportArrowFormatStr(
case TypeKind::TIMESTAMP:
switch (options.timestampUnit) {
case TimestampUnit::kSecond:
return "tss";
return "tss:";
case TimestampUnit::kMilli:
return "tsm";
return "tsm:";
case TimestampUnit::kMicro:
return "tsu";
return "tsu:";
case TimestampUnit::kNano:
return "tsn";
return "tsn:";
default:
VELOX_UNREACHABLE();
}
Expand Down
6 changes: 3 additions & 3 deletions velox/vector/arrow/tests/ArrowBridgeArrayTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ class ArrowBridgeArrayImportTest : public ArrowBridgeArrayExportTest {
testArrowImport<double>("g", {-99.9, 4.3, 31.1, 129.11, -12});
testArrowImport<float>("f", {-99.9, 4.3, 31.1, 129.11, -12});

for (const std::string& tsString : {"tss", "tsm", "tsu", "tsn"}) {
for (const std::string& tsString : {"tss:", "tsm:", "tsu:", "tsn:"}) {
testArrowImport<Timestamp, int64_t>(
tsString.data(), {0, std::nullopt, 1699308257000001234});
}
Expand Down Expand Up @@ -1672,7 +1672,7 @@ TEST_F(ArrowBridgeArrayImportAsViewerTest, scalar) {
TEST_F(ArrowBridgeArrayImportAsViewerTest, without_nulls_buffer) {
std::vector<std::optional<int64_t>> inputValues = {1, 2, 3, 4, 5};
testImportWithoutNullsBuffer<int64_t>(inputValues, "l");
testImportWithoutNullsBuffer<Timestamp>(inputValues, "tsn");
testImportWithoutNullsBuffer<Timestamp>(inputValues, "tsn:");
}

TEST_F(ArrowBridgeArrayImportAsViewerTest, string) {
Expand Down Expand Up @@ -1725,7 +1725,7 @@ TEST_F(ArrowBridgeArrayImportAsOwnerTest, scalar) {
TEST_F(ArrowBridgeArrayImportAsOwnerTest, without_nulls_buffer) {
std::vector<std::optional<int64_t>> inputValues = {1, 2, 3, 4, 5};
testImportWithoutNullsBuffer<int64_t>(inputValues, "l");
testImportWithoutNullsBuffer<Timestamp>(inputValues, "tsn");
testImportWithoutNullsBuffer<Timestamp>(inputValues, "tsn:");
}

TEST_F(ArrowBridgeArrayImportAsOwnerTest, string) {
Expand Down
14 changes: 7 additions & 7 deletions velox/vector/arrow/tests/ArrowBridgeSchemaTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ TEST_F(ArrowBridgeSchemaExportTest, scalar) {
testScalarType(VARBINARY(), "z");

options_.timestampUnit = TimestampUnit::kSecond;
testScalarType(TIMESTAMP(), "tss");
testScalarType(TIMESTAMP(), "tss:");
options_.timestampUnit = TimestampUnit::kMilli;
testScalarType(TIMESTAMP(), "tsm");
testScalarType(TIMESTAMP(), "tsm:");
options_.timestampUnit = TimestampUnit::kMicro;
testScalarType(TIMESTAMP(), "tsu");
testScalarType(TIMESTAMP(), "tsu:");
options_.timestampUnit = TimestampUnit::kNano;
testScalarType(TIMESTAMP(), "tsn");
testScalarType(TIMESTAMP(), "tsn:");

testScalarType(DATE(), "tdD");

Expand Down Expand Up @@ -370,7 +370,7 @@ TEST_F(ArrowBridgeSchemaImportTest, scalar) {
EXPECT_EQ(*VARBINARY(), *testSchemaImport("Z"));

// Temporal.
EXPECT_EQ(*TIMESTAMP(), *testSchemaImport("tsu"));
EXPECT_EQ(*TIMESTAMP(), *testSchemaImport("tsu:"));
EXPECT_EQ(*DATE(), *testSchemaImport("tdD"));

EXPECT_EQ(*DECIMAL(10, 4), *testSchemaImport("d:10,4"));
Expand All @@ -383,7 +383,7 @@ TEST_F(ArrowBridgeSchemaImportTest, scalar) {
TEST_F(ArrowBridgeSchemaImportTest, complexTypes) {
// Array.
EXPECT_EQ(*ARRAY(BIGINT()), *testSchemaImportComplex("+l", {"l"}));
EXPECT_EQ(*ARRAY(TIMESTAMP()), *testSchemaImportComplex("+l", {"tsn"}));
EXPECT_EQ(*ARRAY(TIMESTAMP()), *testSchemaImportComplex("+l", {"tsn:"}));
EXPECT_EQ(*ARRAY(DATE()), *testSchemaImportComplex("+l", {"tdD"}));
EXPECT_EQ(*ARRAY(VARCHAR()), *testSchemaImportComplex("+l", {"U"}));

Expand Down Expand Up @@ -529,7 +529,7 @@ TEST_F(ArrowBridgeSchemaImportTest, dictionaryTypeTest) {
*testSchemaDictionaryImport(
"i",
makeComplexArrowSchema(
schemas, schemaPtrs, mapSchemas, mapSchemaPtrs, "+l", {"tsn"})));
schemas, schemaPtrs, mapSchemas, mapSchemaPtrs, "+l", {"tsn:"})));
EXPECT_EQ(
*ARRAY(DATE()),
*testSchemaDictionaryImport(
Expand Down

0 comments on commit 01969b3

Please sign in to comment.