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

Support query file #14

Open
hakobera opened this issue May 31, 2016 · 1 comment
Open

Support query file #14

hakobera opened this issue May 31, 2016 · 1 comment
Labels

Comments

@hakobera
Copy link
Member

hakobera commented May 31, 2016

BigqueryQuery task only support embedded query parameter. But sometimes we want to write long query which include parameters and load it from file.

So we extend BigqueryQuery task can accept query_file parameter.
query_file is ERB template file and can access attribute of task like:

SELECT
  id
FROM
  table
WHERE
  DATE(time) == <%= @today %>
task task1, type: bigquery_query do
  param :today, auto_bind: true, required: true
  param_set :query_file, 'path/to/query.sql'
end
@hakobera hakobera added this to the v0.2.0 milestone May 31, 2016
@hakobera hakobera changed the title Support template query table Support query file May 31, 2016
@hakobera hakobera modified the milestones: v0.3.0, v0.2.0 Jun 1, 2016
@hakobera
Copy link
Member Author

hakobera commented Jun 1, 2016

umm, I rethink specification, just use lambda is enough? So I move this issue's milestone to v0.3.0, and it is really needed or not.

Current BigqueryQuery support template query using string interpolation + hear document like this:

task task1, type: bigquery_query do
  param :today, auto_bind: true, required: true
  param_set :query, -> {
    >>-SQL
    SELECT
      id
    FROM
      table
    WHERE
      DATE(time) == '#{today}'
    SQL
  }
end

If you are using ruby 2.3+, you can use >>~ to remove leading indent.

@hakobera hakobera modified the milestones: v0.4.0, v0.3.0 Jun 13, 2016
@hakobera hakobera removed this from the v0.4.0 milestone Jul 14, 2016
@hakobera hakobera reopened this Jul 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant