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

Can envelope run nested loops ? #35

Open
sgulati89 opened this issue Feb 14, 2019 · 1 comment
Open

Can envelope run nested loops ? #35

sgulati89 opened this issue Feb 14, 2019 · 1 comment

Comments

@sgulati89
Copy link

Hi,
Can envelope run nested loops ?

For Example how to implement following logic in envelope,

for (String str:values)
{
for(String str1:values2){
somestep(str1,str)
{
}

@jeremybeard
Copy link
Contributor

Hi @sgulati89,

Yes, in general Envelope can run nested loops. In the current version (v0.6.1) this is known to work when the values are provided by a range or by a step. In the next minor version (v0.7.0) this will also work when the values are provided by a list.

Here's an example of using a range for the outer loop and a step for the inner loop:

> cat loop.conf
steps {
  step_source {
    deriver {
      type = sql
      query.literal = "SELECT 1 UNION ALL SELECT 2"
    }
  }

  outer_loop {
    type = loop
    source = range
    range {
      start = 10
      end = 12
    }
    mode = serial
    parameter = outer
  }

  inner_loop {
    dependencies = [outer_loop, step_source]
    type = loop
    source = step
    step = step_source
    mode = serial
    parameter = inner
  }

  print_parameters {
    dependencies = [outer_loop, inner_loop]
    deriver {
      type = sql
      query.literal = "SELECT ${outer} AS outer, ${inner} AS inner"
    }
    print.data.enabled = true
  }
}

> spark-submit envelope-0.6.1.jar loop.conf
...
+-----+-----+
|outer|inner|
+-----+-----+
|   10|    1|
+-----+-----+
...
+-----+-----+
|outer|inner|
+-----+-----+
|   10|    2|
+-----+-----+
...
+-----+-----+
|outer|inner|
+-----+-----+
|   11|    1|
+-----+-----+
...
+-----+-----+
|outer|inner|
+-----+-----+
|   11|    2|
+-----+-----+
...
+-----+-----+
|outer|inner|
+-----+-----+
|   12|    1|
+-----+-----+
...
+-----+-----+
|outer|inner|
+-----+-----+
|   12|    2|
+-----+-----+

Hope that helps.

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