westonpace commented on code in PR #14292:
URL: https://github.com/apache/arrow/pull/14292#discussion_r1045247283
##########
cpp/src/arrow/engine/substrait/serde_test.cc:
##########
@@ -2331,8 +2332,8 @@ TEST(Substrait, ProjectRel) {
ConversionOptions conversion_options;
conversion_options.named_table_provider = std::move(table_provider);
- CheckRoundTripResult(std::move(output_schema), std::move(expected_table),
exec_context,
- buf, {}, conversion_options);
+ CheckRoundTripResult(std::move(expected_table), exec_context, buf, {},
+ conversion_options);
Review Comment:
```suggestion
CheckRoundTripResult(std::move(expected_table), exec_context, buf,
/*include_columns=*/{},
conversion_options);
```
Minor nit
##########
cpp/src/arrow/engine/substrait/serde_test.cc:
##########
@@ -2773,8 +2774,8 @@ TEST(Substrait, JoinRelEndToEnd) {
ConversionOptions conversion_options;
conversion_options.named_table_provider = std::move(table_provider);
- CheckRoundTripResult(std::move(output_schema), std::move(expected_table),
exec_context,
- buf, {}, conversion_options);
+ CheckRoundTripResult(std::move(expected_table), exec_context, buf, {},
Review Comment:
```suggestion
CheckRoundTripResult(std::move(expected_table), exec_context, buf,
/*include_columns=*/{},
```
##########
cpp/src/arrow/engine/substrait/serde_test.cc:
##########
@@ -2624,8 +2625,8 @@ TEST(Substrait, FilterRelWithEmit) {
ConversionOptions conversion_options;
conversion_options.named_table_provider = std::move(table_provider);
- CheckRoundTripResult(std::move(output_schema), std::move(expected_table),
exec_context,
- buf, {}, conversion_options);
+ CheckRoundTripResult(std::move(expected_table), exec_context, buf, {},
Review Comment:
```suggestion
CheckRoundTripResult(std::move(expected_table), exec_context, buf,
/*include_columns=*/{},
```
##########
cpp/src/arrow/engine/substrait/serde_test.cc:
##########
@@ -3032,8 +3033,8 @@ TEST(Substrait, AggregateRel) {
ConversionOptions conversion_options;
conversion_options.named_table_provider = std::move(table_provider);
- CheckRoundTripResult(std::move(output_schema), std::move(expected_table),
exec_context,
- buf, {}, conversion_options);
+ CheckRoundTripResult(std::move(expected_table), exec_context, buf, {},
Review Comment:
```suggestion
CheckRoundTripResult(std::move(expected_table), exec_context, buf,
/*include_columns=*/{},
```
##########
cpp/src/arrow/engine/substrait/serde_test.cc:
##########
@@ -2449,8 +2450,8 @@ TEST(Substrait, ProjectRelOnFunctionWithEmit) {
ConversionOptions conversion_options;
conversion_options.named_table_provider = std::move(table_provider);
- CheckRoundTripResult(std::move(output_schema), std::move(expected_table),
exec_context,
- buf, {}, conversion_options);
+ CheckRoundTripResult(std::move(expected_table), exec_context, buf, {},
+ conversion_options);
Review Comment:
```suggestion
CheckRoundTripResult(std::move(expected_table), exec_context, buf,
/*include_columns=*/{},
conversion_options);
```
##########
cpp/src/arrow/engine/substrait/serde_test.cc:
##########
@@ -3504,8 +3505,8 @@ TEST(Substrait, NestedProjectWithMultiFieldExpressions) {
ConversionOptions conversion_options;
conversion_options.named_table_provider = std::move(table_provider);
- CheckRoundTripResult(std::move(output_schema), std::move(expected_table),
exec_context,
- buf, {}, conversion_options);
+ CheckRoundTripResult(std::move(expected_table), exec_context, buf, {},
Review Comment:
```suggestion
CheckRoundTripResult(std::move(expected_table), exec_context, buf,
/*include_columns=*/{},
```
##########
cpp/src/arrow/engine/substrait/serde_test.cc:
##########
@@ -3687,10 +3688,120 @@ TEST(Substrait, ReadRelWithGlobFiles) {
}
}]
})"));
-
+ // To avoid unnecessar meta data columns being included in the final result
+ std::vector<int> include_columns = {0, 1, 2};
compute::SortOptions options({compute::SortKey("A",
compute::SortOrder::Ascending)});
- CheckRoundTripResult(std::move(dummy_schema), std::move(expected_table),
exec_context,
- buf, {}, {}, &options);
+ CheckRoundTripResult(std::move(expected_table), exec_context, buf,
+ std::move(include_columns), {}, &options);
Review Comment:
```suggestion
std::move(include_columns),
/*conversion_options=*/{}, &options);
```
##########
cpp/src/arrow/engine/substrait/serde_test.cc:
##########
@@ -3687,10 +3688,120 @@ TEST(Substrait, ReadRelWithGlobFiles) {
}
}]
})"));
-
+ // To avoid unnecessar meta data columns being included in the final result
Review Comment:
```suggestion
// To avoid unnecessary metadata columns being included in the final result
```
##########
cpp/src/arrow/engine/substrait/serde_test.cc:
##########
@@ -3687,10 +3688,120 @@ TEST(Substrait, ReadRelWithGlobFiles) {
}
}]
})"));
-
+ // To avoid unnecessar meta data columns being included in the final result
+ std::vector<int> include_columns = {0, 1, 2};
compute::SortOptions options({compute::SortKey("A",
compute::SortOrder::Ascending)});
- CheckRoundTripResult(std::move(dummy_schema), std::move(expected_table),
exec_context,
- buf, {}, {}, &options);
+ CheckRoundTripResult(std::move(expected_table), exec_context, buf,
+ std::move(include_columns), {}, &options);
+}
+
+TEST(Substrait, RootRelationOutputNames) {
+ compute::ExecContext exec_context;
+ auto dummy_schema =
+ schema({field("A", int32()), field("B", int32()), field("C", int32())});
+
+ // creating a dummy dataset using a dummy table
+ const std::vector<std::string> str_data_vec = {
+ R"([
+ [10, 1, 80],
+ [20, 2, 70],
+ [30, 3, 30]
+ ])"};
+ auto input_table = TableFromJSON(dummy_schema, str_data_vec);
+
+ const std::string substrait_json = R"({
+ "relations": [{
+ "root": {
+ "input": {
+ "project": {
+ "common": {
+ "emit": {
+ "outputMapping": [3, 4, 5]
+ }
+ },
+ "input": {
+ "read": {
+ "common": {
+ "direct": {
+ }
+ },
+ "baseSchema": {
+ "names": ["A", "B", "C"],
+ "struct": {
+ "types": [{
+ "i32": {
+ "typeVariationReference": 0,
+ "nullability": "NULLABILITY_REQUIRED"
+ }
+ }, {
+ "i32": {
+ "typeVariationReference": 0,
+ "nullability": "NULLABILITY_REQUIRED"
+ }
+ }, {
+ "i32": {
+ "typeVariationReference": 0,
+ "nullability": "NULLABILITY_REQUIRED"
+ }
+ }],
+ "typeVariationReference": 0,
+ "nullability": "NULLABILITY_REQUIRED"
+ }
+ },
+ "namedTable": {
+ "names": ["SIMPLEDATA"]
+ }
+ }
+ },
+ "expressions": [{
+ "selection": {
+ "directReference": {
+ "structField": {
+ "field": 0
+ }
+ },
+ "rootReference": {
+ }
+ }
+ }, {
+ "selection": {
+ "directReference": {
+ "structField": {
+ "field": 1
+ }
+ },
+ "rootReference": {
+ }
+ }
+ }, {
+ "selection": {
+ "directReference": {
+ "structField": {
+ "field": 2
+ }
+ },
+ "rootReference": {
+ }
+ }
+ }]
+ }
+ },
+ "names": ["X", "Y", "Z"]
+ }
+ }]
+ })";
+
+ ASSERT_OK_AND_ASSIGN(auto buf, internal::SubstraitFromJSON("Plan",
substrait_json));
+ auto output_schema =
+ schema({field("X", int32()), field("Y", int32()), field("Z", int32())});
+ auto expected_table = TableFromJSON(output_schema, str_data_vec);
+
+ NamedTableProvider table_provider =
AlwaysProvideSameTable(std::move(input_table));
+
+ ConversionOptions conversion_options;
+ conversion_options.named_table_provider = std::move(table_provider);
+ CheckRoundTripResult(std::move(expected_table), exec_context, buf, {},
Review Comment:
```suggestion
CheckRoundTripResult(std::move(expected_table), exec_context, buf,
/*include_columns=*/{},
```
##########
cpp/src/arrow/engine/substrait/serde_test.cc:
##########
@@ -3146,8 +3147,8 @@ TEST(Substrait, AggregateRelEmit) {
ConversionOptions conversion_options;
conversion_options.named_table_provider = std::move(table_provider);
- CheckRoundTripResult(std::move(output_schema), std::move(expected_table),
exec_context,
- buf, {}, conversion_options);
+ CheckRoundTripResult(std::move(expected_table), exec_context, buf, {},
Review Comment:
```suggestion
CheckRoundTripResult(std::move(expected_table), exec_context, buf,
/*include_columns=*/{},
```
##########
cpp/src/arrow/engine/substrait/serde_test.cc:
##########
@@ -2924,8 +2925,8 @@ TEST(Substrait, JoinRelWithEmit) {
ConversionOptions conversion_options;
conversion_options.named_table_provider = std::move(table_provider);
- CheckRoundTripResult(std::move(output_schema), std::move(expected_table),
exec_context,
- buf, {}, conversion_options);
+ CheckRoundTripResult(std::move(expected_table), exec_context, buf, {},
Review Comment:
```suggestion
CheckRoundTripResult(std::move(expected_table), exec_context, buf,
/*include_columns=*/{},
```
##########
cpp/src/arrow/engine/substrait/serde_test.cc:
##########
@@ -2507,8 +2508,8 @@ TEST(Substrait, ReadRelWithEmit) {
ConversionOptions conversion_options;
conversion_options.named_table_provider = std::move(table_provider);
- CheckRoundTripResult(std::move(output_schema), std::move(expected_table),
exec_context,
- buf, {}, conversion_options);
+ CheckRoundTripResult(std::move(expected_table), exec_context, buf, {},
Review Comment:
```suggestion
CheckRoundTripResult(std::move(expected_table), exec_context, buf,
/*include_columns=*/{},
```
##########
cpp/src/arrow/engine/substrait/serde_test.cc:
##########
@@ -3416,8 +3417,8 @@ TEST(Substrait, ProjectWithMultiFieldExpressions) {
ConversionOptions conversion_options;
conversion_options.named_table_provider = std::move(table_provider);
- CheckRoundTripResult(std::move(output_schema), std::move(expected_table),
exec_context,
- buf, {}, conversion_options);
+ CheckRoundTripResult(std::move(expected_table), exec_context, buf, {},
Review Comment:
```suggestion
CheckRoundTripResult(std::move(expected_table), exec_context, buf,
/*include_columns=*/{},
```
##########
cpp/src/arrow/engine/substrait/serde_test.cc:
##########
@@ -3593,8 +3594,8 @@ TEST(Substrait,
NestedEmitProjectWithMultiFieldExpressions) {
ConversionOptions conversion_options;
conversion_options.named_table_provider = std::move(table_provider);
- CheckRoundTripResult(std::move(output_schema), std::move(expected_table),
exec_context,
- buf, {}, conversion_options);
+ CheckRoundTripResult(std::move(expected_table), exec_context, buf, {},
Review Comment:
```suggestion
CheckRoundTripResult(std::move(expected_table), exec_context, buf,
/*include_columns=*/{},
```
##########
cpp/src/arrow/engine/substrait/serde_test.cc:
##########
@@ -3257,8 +3258,8 @@ TEST(Substrait, IsthmusPlan) {
/*ignore_unknown_fields=*/false));
auto expected_table = TableFromJSON(test_schema, {"[[2], [3], [6]]"});
- CheckRoundTripResult(std::move(test_schema), std::move(expected_table),
- *compute::default_exec_context(), buf, {},
conversion_options);
+ CheckRoundTripResult(std::move(expected_table),
*compute::default_exec_context(), buf,
+ {}, conversion_options);
Review Comment:
```suggestion
/*include_columns=*/{}, conversion_options);
```
--
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]