You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/10/14 07:59:04 UTC

[GitHub] [arrow] jorisvandenbossche commented on a diff in pull request #14326: ARROW-14596: [C++][Python] Read table nested struct fields in columns

jorisvandenbossche commented on code in PR #14326:
URL: https://github.com/apache/arrow/pull/14326#discussion_r995464387


##########
cpp/src/arrow/dataset/scanner_test.cc:
##########
@@ -1074,6 +1074,24 @@ TEST_P(TestScanner, ProjectedScanNested) {
   AssertScanBatchesUnorderedEqualRepetitionsOf(MakeScanner(batch_in), batch_out);
 }
 
+TEST_P(TestScanner, ProjectedScanNestedFromNames) {
+  SetSchema({
+      field("struct", struct_({field("i32", int32()), field("f64", float64())})),
+      field("nested", struct_({field("left", int32()),
+                               field("right", struct_({field("i32", int32()),
+                                                       field("f64", float64())}))})),
+  });
+  ASSERT_OK_AND_ASSIGN(auto descr,
+                       ProjectionDescr::FromNames({"struct.i32", "nested.right.f64"},
+                                                  *options_->dataset_schema))
+  SetProjection(options_.get(), std::move(descr));
+  auto batch_in = ConstantArrayGenerator::Zeroes(GetParam().items_per_batch, schema_);
+  auto batch_out = ConstantArrayGenerator::Zeroes(
+      GetParam().items_per_batch,
+      schema({field("struct.i32", int32()), field("nested.right.f64", float64())}));

Review Comment:
   I would have expected the field names here to be "i32" and "f64"? (consistent with the test above) 



##########
cpp/src/arrow/dataset/scanner_test.cc:
##########
@@ -1074,6 +1074,24 @@ TEST_P(TestScanner, ProjectedScanNested) {
   AssertScanBatchesUnorderedEqualRepetitionsOf(MakeScanner(batch_in), batch_out);
 }
 
+TEST_P(TestScanner, ProjectedScanNestedFromNames) {
+  SetSchema({
+      field("struct", struct_({field("i32", int32()), field("f64", float64())})),
+      field("nested", struct_({field("left", int32()),
+                               field("right", struct_({field("i32", int32()),
+                                                       field("f64", float64())}))})),
+  });
+  ASSERT_OK_AND_ASSIGN(auto descr,
+                       ProjectionDescr::FromNames({"struct.i32", "nested.right.f64"},

Review Comment:
   ```suggestion
                          ProjectionDescr::FromNames({".struct.i32", "nested.right.f64"},
   ```
   
   (so we cover both with and without leading dot)



-- 
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: github-unsubscribe@arrow.apache.org

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