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/05/30 07:04:37 UTC

[GitHub] [arrow-datafusion] kou commented on pull request #2622: Export minimum C API and examples for C, Ruby and Python

kou commented on PR #2622:
URL: https://github.com/apache/arrow-datafusion/pull/2622#issuecomment-1140777959

   Regarding repository, I'm OK with it. Could you create https://github.com/datafusion-contrib/datafusion-c or something? Or should I create my repository for this?
   
   > I'm also curious why we would want to go from Python -> C -> Rust rather than just Python -> Rust directly as we do in https://github.com/datafusion-contrib/datafusion-python
   
   Sorry for confusing you. I didn't want to suggest that we should use this for Python bindings. I just wanted to show that we can use FFI library for bindings as an use case of this C API. I should have used Julia or something rather than Python.
   
   > * It would be nice to put a minimal readme in `datafusion/c` (saying, for example, that the directory contains the C API, see `examples/README.md` for more details). Or maybe we could move `datafusion/c/examples/README.md` to `datafusion/c/README.md` to make it more discoverable
   > 
   > * I think it would be a good idea to track planned follow on items as individual tasks
   
   They make sense. I'll do them in new repository for this.
   
   > I am not familiar how to interface Rust `async` functions with C -- I would assume it looks like callbacks somehow, but I can imagine how it gets very tricky very quickly
   
   I will not use callbacks like the following:
   
   ```c
   int
   main(void)
   {
     DFSessionContext *context = df_session_context_new();
     DFError *error = NULL;
   
     DFDataFrameFuture *sql_future =
       df_session_context_sql_async(context, "SELECT 1;", &error);
     if (error) {
       printf("failed to start SQL: %s\n", df_error_get_message(error));
       df_error_free(error);
       df_session_context_free(context);
       return EXIT_FAILURE;
     }
   
     DFDataFrame *data_frame = df_data_frame_future_await(sql_future, &error);
     if (error) {
       printf("failed to run SQL: %s\n", df_error_get_message(error));
       df_error_free(error);
       df_session_context_free(context);
       return EXIT_FAILURE;
     }
   
     DFFuture *show_future = df_data_frame_show_async(data_frame, &error);
     if (error) {
       printf("failed to start showing data frame: %s\n",
              df_error_get_message(error));
       df_error_free(error);
       df_data_frame_free(data_frame);
       return EXIT_FAILURE;
     }
   
     df_future_await(show_future, &error);
     if (error) {
       printf("failed to show data frame: %s\n",
              df_error_get_message(error));
       df_error_free(error);
       df_data_frame_free(data_frame);
       return EXIT_FAILURE;
     }
   
     df_data_frame_free(data_frame);
     df_session_context_free(context);
     return EXIT_SUCCESS;
   }
   ```
   
   But I may change my mind.
   
   
   Thanks for suggestions for my Rust code! This is my first Rust program. So suggestions are very welcome. :-)
   


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