js8544 commented on code in PR #14242:
URL: https://github.com/apache/arrow/pull/14242#discussion_r982337752
##########
cpp/src/arrow/json/test_common.h:
##########
@@ -259,5 +259,19 @@ inline static std::string null_src() {
)";
}
+inline static std::string unquoted_decimal_src() {
+ return R"(
+ { "price": 30.04, "cost":30.001 }
+ { "price": 1.23, "cost":1.229 }
+ )";
+}
+
+inline static std::string mixed_decimal_src() {
+ return R"(
+ { "price": 30.04, "cost": "30.001" }
+ { "price": 1.23, "cost": "1.229" }
Review Comment:
You are correct! I've corrected this.
##########
cpp/src/arrow/json/reader_test.cc:
##########
@@ -274,5 +275,35 @@ TEST(ReaderTest, ListArrayWithFewValues) {
AssertTablesEqual(*actual_table, *expected_table);
}
+TEST_P(ReaderTest, UnquotedDecimal) {
+ parse_options_.unexpected_field_behavior =
UnexpectedFieldBehavior::InferType;
+ auto schema =
+ ::arrow::schema({field("price", decimal(9, 2)), field("cost", decimal(9,
3))});
+ parse_options_.explicit_schema = schema;
+ auto src = unquoted_decimal_src();
+ SetUpReader(src);
+ ASSERT_OK_AND_ASSIGN(table_, reader_->Read());
+
+ auto expected_table = Table::Make(
+ schema, {ArrayFromJSON(schema->field(0)->type(), R"(["30.04", "1.23"])"),
+ ArrayFromJSON(schema->field(1)->type(), R"(["30.001",
"1.229"])")});
Review Comment:
Changed to TableFromJSON
--
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]