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

Allow variables in YAML definition of sql batches #26

Closed
mkrcah opened this issue Jan 14, 2015 · 4 comments
Closed

Allow variables in YAML definition of sql batches #26

mkrcah opened this issue Jan 14, 2015 · 4 comments

Comments

@mkrcah
Copy link
Member

mkrcah commented Jan 14, 2015

Sometimes it is needed to perform several sql batches with queries with are almost identical but differ in one parameter. For example:

- query: SELECT * FROM foo WHERE bar = 'Spark rocks!'
  output: spark.csv
- query: SELECT * FROM foo WHERE bar = 'Impala rocks!'
  output: impala.csv
- query: SELECT * FROM foo WHERE bar = 'Hadoop rocks!'
  output: hadoop.csv

Especially for complex sql queries, it would be very useful to provide a mechanism in the YAML batch-sql config to define a for-loop and provide a placeholder in the query and output parameter.

For example, we might follow the path that Ansible chose for loops:

- query: SELECT * FROM foo WHERE bar = '{{item}} rocks!'
  with_items:
  - "Spark"
  - "Impala"
  - "Hadoop"
  output: {{item}}.csv
@DonDebonair
Copy link
Member

This is already possible, but it wasn't in the README yet ;) In fact, I was just writing a paragraph about it.

@mkrcah
Copy link
Member Author

mkrcah commented Jan 14, 2015

Haha, I thought you are doing some heavy refactoring :)

Hopefully, this hard replacement of {{ item }} would suffice, let's see in practice.

@DonDebonair
Copy link
Member

There was some heavy refactoring, but the old construct you created for repeatable queries is still there. I think we should roll with it, and make it more comprehensive only when the need arises.

@mkrcah
Copy link
Member Author

mkrcah commented Jan 14, 2015

Agreed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants