pitrou commented on code in PR #14741:
URL: https://github.com/apache/arrow/pull/14741#discussion_r1048711745


##########
cpp/src/arrow/json/reader_test.cc:
##########
@@ -325,6 +335,108 @@ TEST(ReaderTest, FailOnInvalidEOF) {
   }
 }
 
+// ARROW-18106
+TEST(ReaderTest, FailOnTimeUnitMismatch) {
+  std::string json = R"({"t":"2022-09-05T08:08:46.000"})";
+
+  auto read_options = ReadOptions::Defaults();
+  read_options.use_threads = false;
+  auto parse_options = ParseOptions::Defaults();
+  parse_options.explicit_schema = schema({field("t", 
timestamp(TimeUnit::SECOND))});
+
+  std::shared_ptr<io::InputStream> input;
+  std::shared_ptr<TableReader> reader;
+  for (auto behavior : {UnexpectedFieldBehavior::Error, 
UnexpectedFieldBehavior::Ignore,
+                        UnexpectedFieldBehavior::InferType}) {
+    parse_options.unexpected_field_behavior = behavior;
+    EXPECT_RAISES_WITH_MESSAGE_THAT(
+        Invalid,
+        ::testing::StartsWith("Invalid: Failed of conversion of JSON to 
timestamp[s]"),

Review Comment:
   I hadn't noticed this before (it predates your PR), but is "Failed of 
conversion" grammatically correct?



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to