You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2024/03/21 13:45:23 UTC

Re: [I] Add extension plugin to parse SQL into logical plan / user defined SQL parser [arrow-datafusion]

alamb commented on issue #533:
URL: https://github.com/apache/arrow-datafusion/issues/533#issuecomment-2012348130

   @tshauck mentioned this in discord: https://discord.com/channels/885562378132000778/1166447479609376850/1219782560436191342
   
   -------
   
   Hi, I'm wondering if someone could give some advice on how to use DFParser in my own parser. It's impl is:
   
   ```rust
   pub struct DFParser<'a> {
       parser: Parser<'a>,
   }
   ```
   
   And basically I want to do:
   ```rust
   pub struct MyParser<'a> {
       parser: DFParser<'a>,
   }
   ```
   
   so I can reuse as much as possible (e.g. parse_statement), but implement my own parsing logic on Keyword::COPY. The issue I'm having is that it doesn't seem possible to access the underlying sqlparser Parser as it's private to DFParser. At least with this approach I'd need access to it so I could call next_token() and other methods.
   
   Is there a better approach to adding something like that on top of the DFParser, or would the maintainers be open to making parser available for modification on DFParser struct.
   
   Put another way, the end goal is to customize how the SQL becomes a logical plan so I can use CopyTo and a user defined logical node to write to a custom file format.
   
   Thanks!
   
   For reference, here's parse_statement: https://github.com/apache/arrow-datafusion/blob/8074ca1e758470319699a562074290906003b312/datafusion/sql/src/parser.rs#L352-L384 
   


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