You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Dewey Dunnington (Jira)" <ji...@apache.org> on 2022/10/03 13:14:00 UTC

[jira] [Created] (ARROW-17915) [C++] Error when using Substrait ProjectRel

Dewey Dunnington created ARROW-17915:
----------------------------------------

             Summary: [C++] Error when using Substrait ProjectRel
                 Key: ARROW-17915
                 URL: https://issues.apache.org/jira/browse/ARROW-17915
             Project: Apache Arrow
          Issue Type: Bug
          Components: C++
            Reporter: Dewey Dunnington


After ARROW-16989 and ARROW-15584, there is new behaviour with ProjectRel. I implemented a solution that worked with DuckDB's consumer in , but when I try with Arrow's compiler I get an error:

{code:R}
library(arrow, warn.conflicts = FALSE)

plan_as_json <- '{
  "extensionUris": [
    {
      "extensionUriAnchor": 1,
      "uri": "https://github.com/apache/arrow/blob/master/format/substrait/extension_types.yaml"
    }
  ],
  "relations": [
    {
      "rel": {
        "project": {
          "common": {"emit": {"outputMapping": [3, 4]}},
          "input": {
            "read": {
              "baseSchema": {
                "names": ["int", "dbl"],
                "struct": {"types": [{"i32": {}}, {"fp64": {}}]}
              },
              "localFiles": {
                "items": [
                  {
                    "uriFile": "file://THIS_IS_THE_TEMP_FILE",
                    "parquet": {}
                  }
                ]
              }
            }
          },
          "expressions": [
            {"selection": {"directReference": {"structField": {"field": 1}}}},
            {"selection": {"directReference": {"structField": {"field": 0}}}}
          ]
        }
      }
    }
  ]
}'

temp_parquet <- tempfile()
write_parquet(data.frame(int = integer(), dbl = double()), temp_parquet)
plan_as_json <- gsub("THIS_IS_THE_TEMP_FILE", temp_parquet, plan_as_json)
arrow:::do_exec_plan_substrait(plan_as_json)
#> Error: Invalid: Invalid column index to add field.
#> /Users/dewey/Desktop/rscratch/arrow/cpp/src/arrow/engine/substrait/relation_internal.cc:338  project_schema->AddField( num_columns + static_cast<int>(project.expressions().size()) - 1, std::move(project_field))
#> /Users/dewey/Desktop/rscratch/arrow/cpp/src/arrow/engine/substrait/serde.cc:156  FromProto(plan_rel.has_root() ? plan_rel.root().input() : plan_rel.rel(), ext_set, conversion_options)
{code}

It's admittedly a goofy thing to do: to compute a new column that is an identical copy of an existing column and then discard the original. I can and should simplify the substrait that I'm generating, but maybe this is also valid substrait that should be accepted?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)