Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Parameterized Queries #191

Closed
JHowix opened this issue Oct 19, 2017 · 4 comments

Comments

@JHowix
Copy link

commented Oct 19, 2017

Via https://cloud.google.com/bigquery/docs/parameterized-queries#bigquery-query-params-api it is possible through the API to set and use parameters in a query. It doesn't appear to be possible via the R package.

@riccardopinosio

This comment has been minimized.

Copy link

commented Feb 5, 2018

I second that. I tried today but doesn't seem to be possible as yet. @hadley is it difficult to implement? I might have a look at it myself at some point.

@byapparov

This comment has been minimized.

Copy link
Contributor

commented Mar 5, 2018

I see two options in terms of the how parameters argument can be structured:

# Explicit Type
query_exec(query = "SELECT * FROM orders 
                                    WHERE amount < @max_value AND first_name = @name ", 
                           project = "my-project",
                           parameters = list(max_value = list(type = "INTEGER", value = 10)))

# Implicit Type
query_exec(query = "SELECT * FROM orders 
                                    WHERE amount < @max_value AND first_name = @name ", 
                           project = "my-project",
                           parameters = list(max_value = 10, name = "Bob")))

It seems that other places in the package are relying on the implicit typing (which works most of the time).

I will be happy to write the code for either version, should not be hard. Error handling is the only other unknown for this issue.

@byapparov

This comment has been minimized.

Copy link
Contributor

commented Mar 5, 2018

There is also an option to use positional parameters (?). lets say it is not part of this.

@byapparov

This comment has been minimized.

Copy link
Contributor

commented Mar 10, 2018

@riccardopinosio I have created PR, have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.