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

[I] Support named query parameters [arrow-datafusion]

simonvandel opened a new issue, #8245:
URL: https://github.com/apache/arrow-datafusion/issues/8245

   ### Is your feature request related to a problem or challenge?
   
   https://docs.rs/datafusion/latest/datafusion/dataframe/struct.DataFrame.html#method.with_param_values allows filling query parameters with values. However, each parameter is positional, so that it corresponds to `$1`,`$2` and so forth.
   
   In certain situations, it might be clearer to use named parameters, e.g `$foo`.
   
   ### Describe the solution you'd like
   
   Would it be possible to support named query parameters?
   
   On a cursory look, it seems like the underlying LogicalPlan already supports mapping parameter ids to values, so this might "just" be change the `with_param_values` API. 
   
   ### Describe alternatives you've considered
   
   Keep using positional query parameters. 
   
   ### Additional context
   
   _No response_


-- 
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.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Support named query parameters [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb closed issue #8245: Support named query parameters
URL: https://github.com/apache/arrow-datafusion/issues/8245


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


Re: [I] Support named query parameters [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on issue #8245:
URL: https://github.com/apache/arrow-datafusion/issues/8245#issuecomment-1834504399

   
   > I don't think 1 and 2 need to support named queries, just support 3
   
   I don't fully understand what you are suggesting here. 
   
   I thought the proposal was to change https://docs.rs/datafusion/latest/datafusion/dataframe/struct.DataFrame.html#method.with_param_values to take a different API, perhaps like
   
   ```rust
   pub fn with_param_values(self, param_values: Impl IntoIterator<Item = (&str, ScalarValue)>) -> Result<Self>
   ```
   
   So you could call it like
   ```
   let results = ctx
     .sql("SELECT a FROM example WHERE b = $foo")
     .await?
      // replace $foo with value 2
     .with_param_values(vec![
        "$foo", ScalarValue::from(2i64)
      ])?
     .collect()
     .await?;
   ```
   
   


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


Re: [I] Support named query parameters [arrow-datafusion]

Posted by "Asura7969 (via GitHub)" <gi...@apache.org>.
Asura7969 commented on issue #8245:
URL: https://github.com/apache/arrow-datafusion/issues/8245#issuecomment-1833118781

   I looked at the relevant code, and the placeholders are used in the following three sections:
   1. PREPARE Statement
   2. Insert Statement
   3. Select Statement (query)
   
   I don't think 1 and 2 need to support named queries, just support 3
   This is is preliminary thinking. If you have some idea please advice.
   @alamb @simonvandel 


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


Re: [I] Support named query parameters [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on issue #8245:
URL: https://github.com/apache/arrow-datafusion/issues/8245#issuecomment-1817016724

   I agree @simonvandel  this is both a good idea, and would be a straightforward change 


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


Re: [I] Support named query parameters [arrow-datafusion]

Posted by "Asura7969 (via GitHub)" <gi...@apache.org>.
Asura7969 commented on issue #8245:
URL: https://github.com/apache/arrow-datafusion/issues/8245#issuecomment-1835189676

   > So you could call it like
   > 
   > ```
   > let results = ctx
   >   .sql("SELECT a FROM example WHERE b = $foo")
   >   .await?
   >    // replace $foo with value 2
   >   .with_param_values(vec![
   >      "$foo", ScalarValue::from(2i64)
   >    ])?
   >   .collect()
   >   .await?;
   > ```
   
   Maybe I can't describe it clearly, but my thoughts are the same as yours,thanks


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