You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@orc.apache.org by GitBox <gi...@apache.org> on 2021/04/08 02:11:05 UTC

[GitHub] [orc] wgtmac commented on a change in pull request #675: ORC-666: [C++] Add timestamp with local timezone

wgtmac commented on a change in pull request #675:
URL: https://github.com/apache/orc/pull/675#discussion_r609207683



##########
File path: c++/test/TestWriter.cc
##########
@@ -699,6 +705,172 @@ namespace orc {
     }
   }
 
+  void testWriteTimestampWithTimezone(FileVersion fileVersion,
+                                      const char* writerTimezone,
+                                      const char* readerTimezone,
+                                      const std::string& tsStr,
+                                      int isDst = 0) {
+    char* tzBk = getenv("TZ");  // backup TZ env
+
+    MemoryOutputStream memStream(DEFAULT_MEM_STREAM_SIZE);
+    MemoryPool* pool = getDefaultPool();
+    std::unique_ptr<Type> type(Type::buildTypeFromString("struct<col1:timestamp>"));
+
+    uint64_t stripeSize = 16 * 1024;
+    uint64_t compressionBlockSize = 1024;
+    uint64_t rowCount = 1;
+
+    std::unique_ptr<Writer> writer = createWriter(stripeSize,
+                                                  compressionBlockSize,
+                                                  CompressionKind_ZLIB,
+                                                  *type,
+                                                  pool,
+                                                  &memStream,
+                                                  fileVersion,
+                                                  0,
+                                                  writerTimezone);
+    auto batch = writer->createRowBatch(rowCount);
+    auto& structBatch = dynamic_cast<StructVectorBatch&>(*batch);
+    auto& tsBatch = dynamic_cast<TimestampVectorBatch&>(*structBatch.fields[0]);
+
+    // write timestamp in the writer timezone
+#ifdef _WIN32

Review comment:
       I'd rather not expose platform specific logic and put it into Adaptor.hh.in and Adaptor.cc. See https://github.com/apache/orc/blob/master/c%2B%2B/src/Adaptor.cc#L46 for example.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org