You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "icexelloss (via GitHub)" <gi...@apache.org> on 2023/02/21 16:26:17 UTC

[GitHub] [arrow] icexelloss opened a new pull request, #34279: GH-34278: [C++] Expose schema in named table provider

icexelloss opened a new pull request, #34279:
URL: https://github.com/apache/arrow/pull/34279

   <!--
   Thanks for opening a pull request!
   If this is your first pull request you can find detailed information on how 
   to contribute here:
     * [New Contributor's Guide](https://arrow.apache.org/docs/dev/developers/guide/step_by_step/pr_lifecycle.html#reviews-and-merge-of-the-pull-request)
     * [Contributing Overview](https://arrow.apache.org/docs/dev/developers/overview.html)
   
   
   If this is not a [minor PR](https://github.com/apache/arrow/blob/main/CONTRIBUTING.md#Minor-Fixes). Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose
   
   Opening GitHub issues ahead of time contributes to the [Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.) of the Apache Arrow project.
   
   Then could you also rename the pull request title in the following format?
   
       GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
   
   or
   
       MINOR: [${COMPONENT}] ${SUMMARY}
   
   In the case of PARQUET issues on JIRA the title also supports:
   
       PARQUET-${JIRA_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
   
   -->
   
   ### Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   ### What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   ### Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   ### Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please uncomment the line below and explain which changes are breaking.
   -->
   <!-- **This PR includes breaking changes to public APIs.** -->
   
   <!--
   Please uncomment the line below (and provide explanation) if the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld). We use this to highlight fixes to issues that may affect users without their knowledge. For this reason, fixing bugs that cause errors don't count, since those are usually obvious.
   -->
   <!-- **This PR contains a "Critical Fix".** -->


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


[GitHub] [arrow] icexelloss commented on a diff in pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #34279:
URL: https://github.com/apache/arrow/pull/34279#discussion_r1113402829


##########
cpp/src/arrow/engine/substrait/serde_test.cc:
##########
@@ -3049,21 +3055,22 @@ TEST(SubstraitRoundTrip, JoinRel) {
       [10, 1, 10, 11]
   ])"});
 
-  NamedTableProvider table_provider =
-      [left_table, right_table](const std::vector<std::string>& names) {
-        std::shared_ptr<Table> output_table;
-        for (const auto& name : names) {
-          if (name == "left") {
-            output_table = left_table;
-          }
-          if (name == "right") {
-            output_table = right_table;
-          }
-        }
-        std::shared_ptr<compute::ExecNodeOptions> options =
-            std::make_shared<compute::TableSourceNodeOptions>(std::move(output_table));
-        return compute::Declaration("table_source", {}, options, "mock_source");
-      };
+  NamedTableProvider table_provider = [left_table, right_table](

Review Comment:
   Only interface and format change here 



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


[GitHub] [arrow] westonpace commented on a diff in pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on code in PR #34279:
URL: https://github.com/apache/arrow/pull/34279#discussion_r1114657183


##########
python/pyarrow/_substrait.pyx:
##########
@@ -27,7 +27,7 @@ from pyarrow.includes.libarrow cimport *
 from pyarrow.includes.libarrow_substrait cimport *
 
 
-cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names):
+cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names, const CSchema& schema):

Review Comment:
   I suppose we would eventually want to pass this schema on to the python function correct?
   
   Something like:
   
   ```
       c_schema_sp = shared_ptr[CSchema](schema)
       py_schema = wrap_schema(c_schema_sp)
   
       py_table = named_args["provider"](py_names, py_schema)
   ```
   
   Do you not need this for your use case?



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


[GitHub] [arrow] icexelloss commented on pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on PR #34279:
URL: https://github.com/apache/arrow/pull/34279#issuecomment-1440703139

   @westonpace pushed another revision
   * Fixed lint
   * Addressed https://github.com/apache/arrow/pull/34279#discussion_r1114657183 and exposed schema via python named table provider (also added test and updated the doc)


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


[GitHub] [arrow] icexelloss commented on a diff in pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #34279:
URL: https://github.com/apache/arrow/pull/34279#discussion_r1114674675


##########
python/pyarrow/_substrait.pyx:
##########
@@ -27,7 +27,7 @@ from pyarrow.includes.libarrow cimport *
 from pyarrow.includes.libarrow_substrait cimport *
 
 
-cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names):
+cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names, const CSchema& schema):

Review Comment:
   I can spend a bit time to see if I can get this working on the Python side. Looks like your example code is simple enough.



##########
python/pyarrow/_substrait.pyx:
##########
@@ -27,7 +27,7 @@ from pyarrow.includes.libarrow cimport *
 from pyarrow.includes.libarrow_substrait cimport *
 
 
-cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names):
+cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names, const CSchema& schema):

Review Comment:
   I can spend a bit time to see if I can get this working on for the extension. Looks like your example code is simple enough.



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


[GitHub] [arrow] icexelloss commented on a diff in pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #34279:
URL: https://github.com/apache/arrow/pull/34279#discussion_r1114415375


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -65,8 +65,8 @@ enum class ARROW_ENGINE_EXPORT ConversionStrictness {
   BEST_EFFORT,
 };
 
-using NamedTableProvider =
-    std::function<Result<compute::Declaration>(const std::vector<std::string>&)>;
+using NamedTableProvider = std::function<Result<compute::Declaration>(
+    const std::vector<std::string>&, const std::shared_ptr<Schema>)>;

Review Comment:
   Thanks sense. Will push another revision.



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


[GitHub] [arrow] westonpace commented on a diff in pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on code in PR #34279:
URL: https://github.com/apache/arrow/pull/34279#discussion_r1114875554


##########
python/pyarrow/_substrait.pyx:
##########
@@ -27,7 +27,7 @@ from pyarrow.includes.libarrow cimport *
 from pyarrow.includes.libarrow_substrait cimport *
 
 
-cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names):
+cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names, const CSchema& schema):

Review Comment:
   Hmm, the first error was probably that I didn't point out that you would need to add `c_schema_sp` to your `cdef` section (so cython was recognizing `c_schema_sp` as a python object and not a C++ object).



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


[GitHub] [arrow] icexelloss commented on a diff in pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #34279:
URL: https://github.com/apache/arrow/pull/34279#discussion_r1114579096


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -65,8 +65,8 @@ enum class ARROW_ENGINE_EXPORT ConversionStrictness {
   BEST_EFFORT,
 };
 
-using NamedTableProvider =
-    std::function<Result<compute::Declaration>(const std::vector<std::string>&)>;
+using NamedTableProvider = std::function<Result<compute::Declaration>(
+    const std::vector<std::string>&, const std::shared_ptr<Schema>)>;

Review Comment:
   Changed to `const Schema&`



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


[GitHub] [arrow] icexelloss commented on a diff in pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #34279:
URL: https://github.com/apache/arrow/pull/34279#discussion_r1114889309


##########
python/pyarrow/_substrait.pyx:
##########
@@ -27,7 +27,7 @@ from pyarrow.includes.libarrow cimport *
 from pyarrow.includes.libarrow_substrait cimport *
 
 
-cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names):
+cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names, const CSchema& schema):

Review Comment:
   Ok I pushed another revision - I think this is correct now



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


[GitHub] [arrow] westonpace merged pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace merged PR #34279:
URL: https://github.com/apache/arrow/pull/34279


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


[GitHub] [arrow] ursabot commented on pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "ursabot (via GitHub)" <gi...@apache.org>.
ursabot commented on PR #34279:
URL: https://github.com/apache/arrow/pull/34279#issuecomment-1441397550

   Benchmark runs are scheduled for baseline = 6a0fb7a0cf29ace28962674fa39b658aa096efed and contender = 12c2b38e6bb8aa04ceaeac5f7bef6dab78f8e774. 12c2b38e6bb8aa04ceaeac5f7bef6dab78f8e774 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/6a810f82c900480e9376d98c1510c50e...123ede5369d649fb9006d4e2f97e8c85/)
   [Failed :arrow_down:0.4% :arrow_up:0.0%] [test-mac-arm](https://conbench.ursa.dev/compare/runs/cfbcac9b8bc94a748799278b645cda9c...b4e207a6b7994d77b40dc78b51243cd3/)
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/502b800ca40f46c697b1e9a006012b15...4bdd3e1acdb446b0b10eeef99f45b9da/)
   [Finished :arrow_down:0.25% :arrow_up:0.0%] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/dd6977e69f864208a5aa4d4a15b3f8a2...ee98a05d366441899f8e61e9cfee9d05/)
   Buildkite builds:
   [Finished] [`12c2b38e` ec2-t3-xlarge-us-east-2](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/2420)
   [Finished] [`12c2b38e` test-mac-arm](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/2449)
   [Finished] [`12c2b38e` ursa-i9-9960x](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/2417)
   [Finished] [`12c2b38e` ursa-thinkcentre-m75q](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/2441)
   [Finished] [`6a0fb7a0` ec2-t3-xlarge-us-east-2](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/2419)
   [Failed] [`6a0fb7a0` test-mac-arm](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/2448)
   [Finished] [`6a0fb7a0` ursa-i9-9960x](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/2416)
   [Finished] [`6a0fb7a0` ursa-thinkcentre-m75q](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/2440)
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


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


[GitHub] [arrow] westonpace commented on a diff in pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on code in PR #34279:
URL: https://github.com/apache/arrow/pull/34279#discussion_r1113640124


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -65,8 +65,8 @@ enum class ARROW_ENGINE_EXPORT ConversionStrictness {
   BEST_EFFORT,
 };
 
-using NamedTableProvider =
-    std::function<Result<compute::Declaration>(const std::vector<std::string>&)>;
+using NamedTableProvider = std::function<Result<compute::Declaration>(
+    const std::vector<std::string>&, const std::shared_ptr<Schema>)>;

Review Comment:
   Please use `const Schema&`.  `shared_ptr` should only be needed if the caller is likely to extend ownership.  In the rare case that is needed the caller can just make their own copy.
   
   If you do think it is likely that caller will need to extend ownership you can use `const std::shared_ptr<Schema>&` (`const &` and not just `const`).



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


[GitHub] [arrow] icexelloss commented on a diff in pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #34279:
URL: https://github.com/apache/arrow/pull/34279#discussion_r1114673040


##########
python/pyarrow/_substrait.pyx:
##########
@@ -27,7 +27,7 @@ from pyarrow.includes.libarrow cimport *
 from pyarrow.includes.libarrow_substrait cimport *
 
 
-cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names):
+cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names, const CSchema& schema):

Review Comment:
   Yeah the python side support for this is left out but we only use named table provider via the C++ API.
   
   I didn't do the python side because (1) we don't use it and (2) I am not very familiar with the python C extension. (Took me a while to figure the current C extension changes just to get it working).
   
   



##########
python/pyarrow/_substrait.pyx:
##########
@@ -27,7 +27,7 @@ from pyarrow.includes.libarrow cimport *
 from pyarrow.includes.libarrow_substrait cimport *
 
 
-cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names):
+cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names, const CSchema& schema):

Review Comment:
   Yeah the python side support for this is left out.
   
   I didn't do the python side because (1) we don't use it and (2) I am not very familiar with the python C extension. (Took me a while to figure the current C extension changes just to get it working).
   
   



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


[GitHub] [arrow] icexelloss commented on a diff in pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #34279:
URL: https://github.com/apache/arrow/pull/34279#discussion_r1114688043


##########
python/pyarrow/_substrait.pyx:
##########
@@ -27,7 +27,7 @@ from pyarrow.includes.libarrow cimport *
 from pyarrow.includes.libarrow_substrait cimport *
 
 
-cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names):
+cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names, const CSchema& schema):

Review Comment:
   Hmm I might be importing `wrap_schema` from the wrong place:
   
   ```
   from pyarrow.lib import frombytes, tobytes, wrap_schema
   ```
   
   I think it's complaining about 
   ```
   py_schema = wrap_schema(c_schema_sp)
   ```
   (error trace is weird on the wrong line)



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


[GitHub] [arrow] icexelloss commented on a diff in pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #34279:
URL: https://github.com/apache/arrow/pull/34279#discussion_r1114878590


##########
python/pyarrow/_substrait.pyx:
##########
@@ -27,7 +27,7 @@ from pyarrow.includes.libarrow cimport *
 from pyarrow.includes.libarrow_substrait cimport *
 
 
-cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names):
+cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names, const CSchema& schema):

Review Comment:
   Pushed another revision - added schema to the python named table provider interface (also added test and updated the doc)



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


[GitHub] [arrow] icexelloss commented on a diff in pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #34279:
URL: https://github.com/apache/arrow/pull/34279#discussion_r1113402494


##########
cpp/src/arrow/engine/substrait/serde_test.cc:
##########
@@ -3200,21 +3207,22 @@ TEST(SubstraitRoundTrip, JoinRelWithEmit) {
       [10, 1, 11]
   ])"});
 
-  NamedTableProvider table_provider =
-      [left_table, right_table](const std::vector<std::string>& names) {
-        std::shared_ptr<Table> output_table;
-        for (const auto& name : names) {
-          if (name == "left") {
-            output_table = left_table;
-          }
-          if (name == "right") {
-            output_table = right_table;
-          }
-        }
-        std::shared_ptr<compute::ExecNodeOptions> options =
-            std::make_shared<compute::TableSourceNodeOptions>(std::move(output_table));
-        return compute::Declaration("table_source", {}, options, "mock_source");
-      };
+  NamedTableProvider table_provider = [left_table, right_table](

Review Comment:
   Only interface and format change here 



##########
cpp/src/arrow/engine/substrait/serde_test.cc:
##########
@@ -4114,21 +4123,21 @@ TEST(Substrait, SetRelationBasic) {
       [112, 7, 32]
   ])"});
 
-  NamedTableProvider table_provider = [table1,
-                                       table2](const std::vector<std::string>& names) {
-    std::shared_ptr<Table> output_table;
-    for (const auto& name : names) {
-      if (name == "T1") {
-        output_table = table1;
-      }
-      if (name == "T2") {
-        output_table = table2;
-      }
-    }
-    std::shared_ptr<compute::ExecNodeOptions> options =
-        std::make_shared<compute::TableSourceNodeOptions>(std::move(output_table));
-    return compute::Declaration("table_source", {}, options, "mock_source");
-  };
+  NamedTableProvider table_provider =
+      [table1, table2](const std::vector<std::string>& names, std::shared_ptr<Schema>) {

Review Comment:
   Only interface and format change here 



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


[GitHub] [arrow] icexelloss commented on pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on PR #34279:
URL: https://github.com/apache/arrow/pull/34279#issuecomment-1438888738

   cc @westonpace This should be ready for review


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


[GitHub] [arrow] icexelloss commented on a diff in pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #34279:
URL: https://github.com/apache/arrow/pull/34279#discussion_r1114884741


##########
python/pyarrow/_substrait.pyx:
##########
@@ -27,7 +27,7 @@ from pyarrow.includes.libarrow cimport *
 from pyarrow.includes.libarrow_substrait cimport *
 
 
-cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names):
+cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names, const CSchema& schema):

Review Comment:
   Actually - hold off - I think I didn't handle ownership correctly - should be probably doing a copy instead of move here. Let me see if I can fix.



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


[GitHub] [arrow] github-actions[bot] commented on pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #34279:
URL: https://github.com/apache/arrow/pull/34279#issuecomment-1438766940

   * Closes: #34278


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


[GitHub] [arrow] icexelloss commented on a diff in pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #34279:
URL: https://github.com/apache/arrow/pull/34279#discussion_r1113407751


##########
cpp/src/arrow/engine/substrait/serde_test.cc:
##########
@@ -2309,11 +2310,16 @@ TEST(SubstraitRoundTrip, FilterNamedTable) {
   ])"});
 
   NamedTableProvider table_provider =
-      [&input_table, &table_names](
-          const std::vector<std::string>& names) -> Result<compute::Declaration> {
+    [&input_table, &table_names, &dummy_schema](
+          const std::vector<std::string>& names,
+          const std::shared_ptr<Schema> schema) -> Result<compute::Declaration> {
     if (table_names != names) {
       return Status::Invalid("Table name mismatch");
     }
+    if (!dummy_schema->Equals(*schema)) {

Review Comment:
   Added checks here to ensure schema is passed in correctly.



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


[GitHub] [arrow] icexelloss commented on a diff in pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #34279:
URL: https://github.com/apache/arrow/pull/34279#discussion_r1114683284


##########
python/pyarrow/_substrait.pyx:
##########
@@ -27,7 +27,7 @@ from pyarrow.includes.libarrow cimport *
 from pyarrow.includes.libarrow_substrait cimport *
 
 
-cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names):
+cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names, const CSchema& schema):

Review Comment:
   Hmm, any quick ideas on the error?
   
   ```
       py_names = []
       for i in range(names.size()):
           c_name = names[i]
           py_names.append(frombytes(c_name))
       c_schema_sp = shared_ptr[CSchema](schema)
                                       ^
   ------------------------------------------------------------
   
   pyarrow/_substrait.pyx:42:37: Cannot convert 'shared_ptr[CSchema]' to Python object
   gmake[2]: *** [CMakeFiles/_substrait_pyx.dir/build.make:71: CMakeFiles/_substrait_pyx] Error 1
   gmake[1]: *** [CMakeFiles/Makefile2:785: CMakeFiles/_substrait_pyx.dir/all] Error 2
   ```



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


[GitHub] [arrow] icexelloss commented on a diff in pull request #34279: GH-34278: [C++] Expose schema in named table provider

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #34279:
URL: https://github.com/apache/arrow/pull/34279#discussion_r1114862331


##########
python/pyarrow/_substrait.pyx:
##########
@@ -27,7 +27,7 @@ from pyarrow.includes.libarrow cimport *
 from pyarrow.includes.libarrow_substrait cimport *
 
 
-cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names):
+cdef CDeclaration _create_named_table_provider(dict named_args, const std_vector[c_string]& names, const CSchema& schema):

Review Comment:
   Ok I managed to get extesion to compile with
   
   ```
   c_in_schema = make_shared[CSchema](move(schema))
   ```
   
   Let me fix  the python test next



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