From 01969b3a166eb8eaa774dc4d9a116e928a108c40 Mon Sep 17 00:00:00 2001 From: PHILO-HE Date: Thu, 7 Mar 2024 21:22:56 +0800 Subject: [PATCH] Fix timestamp unit --- velox/vector/arrow/Bridge.cpp | 8 ++++---- velox/vector/arrow/tests/ArrowBridgeArrayTest.cpp | 6 +++--- velox/vector/arrow/tests/ArrowBridgeSchemaTest.cpp | 14 +++++++------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/velox/vector/arrow/Bridge.cpp b/velox/vector/arrow/Bridge.cpp index b442efc414bb..ab7570f1858f 100644 --- a/velox/vector/arrow/Bridge.cpp +++ b/velox/vector/arrow/Bridge.cpp @@ -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(); } diff --git a/velox/vector/arrow/tests/ArrowBridgeArrayTest.cpp b/velox/vector/arrow/tests/ArrowBridgeArrayTest.cpp index 2af776860645..950045bf4524 100644 --- a/velox/vector/arrow/tests/ArrowBridgeArrayTest.cpp +++ b/velox/vector/arrow/tests/ArrowBridgeArrayTest.cpp @@ -1172,7 +1172,7 @@ class ArrowBridgeArrayImportTest : public ArrowBridgeArrayExportTest { testArrowImport("g", {-99.9, 4.3, 31.1, 129.11, -12}); testArrowImport("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( tsString.data(), {0, std::nullopt, 1699308257000001234}); } @@ -1672,7 +1672,7 @@ TEST_F(ArrowBridgeArrayImportAsViewerTest, scalar) { TEST_F(ArrowBridgeArrayImportAsViewerTest, without_nulls_buffer) { std::vector> inputValues = {1, 2, 3, 4, 5}; testImportWithoutNullsBuffer(inputValues, "l"); - testImportWithoutNullsBuffer(inputValues, "tsn"); + testImportWithoutNullsBuffer(inputValues, "tsn:"); } TEST_F(ArrowBridgeArrayImportAsViewerTest, string) { @@ -1725,7 +1725,7 @@ TEST_F(ArrowBridgeArrayImportAsOwnerTest, scalar) { TEST_F(ArrowBridgeArrayImportAsOwnerTest, without_nulls_buffer) { std::vector> inputValues = {1, 2, 3, 4, 5}; testImportWithoutNullsBuffer(inputValues, "l"); - testImportWithoutNullsBuffer(inputValues, "tsn"); + testImportWithoutNullsBuffer(inputValues, "tsn:"); } TEST_F(ArrowBridgeArrayImportAsOwnerTest, string) { diff --git a/velox/vector/arrow/tests/ArrowBridgeSchemaTest.cpp b/velox/vector/arrow/tests/ArrowBridgeSchemaTest.cpp index f56f15f6d428..b1de423442fa 100644 --- a/velox/vector/arrow/tests/ArrowBridgeSchemaTest.cpp +++ b/velox/vector/arrow/tests/ArrowBridgeSchemaTest.cpp @@ -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"); @@ -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")); @@ -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"})); @@ -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(