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

[ETL] Add support for "to" initializers #125

Open
agarciadom opened this issue Oct 9, 2024 · 0 comments
Open

[ETL] Add support for "to" initializers #125

agarciadom opened this issue Oct 9, 2024 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@agarciadom
Copy link
Contributor

In some scenarios, we may want to be able to initialise a to parameter in an ETL rule. For example, if we have an abstract supertype Coin and two concrete subtypes GoldCoin and SilverCoin, we may want to have one rule that transforms a Score into a GoldCoin or a SilverCoin depending on the information of the Score.

Current behaviour

At the moment, doing this would require using at least two rules:

rule Score2GoldCoin from s: Source!Score to c: Target!GoldCoin {
  guard: /* condition to create a gold coin */
  /* set details of c */
}

rule Score2SilverCoin from s: Source!Score to c: Target!SilverCoin {
  guard: /* condition to create a silver coin */
  /* set details of c */
}

We might have common information to set for all coins, so this might be further expanded to three rules with inheritance:

@abstract
rule Score2Coin from s: Source!Score to c: Target!Coin {
  /* set common Coin details of c */
}

rule Score2GoldCoin from s: Source!Score to c: Target!GoldCoin extends Score2Coin {
  guard: /* condition to create a gold coin */
  /* set GoldCoin-specific details of c */
}

rule Score2SilverCoin from s: Source!Score to c: Target!SilverCoin extends Score2Coin {
  guard: /* condition to create a silver coin */
  /* set SilverCoin-specific details of c */
}

Desired behaviour

It would be good to support a syntax like this:

rule Score2Coin
  from s: Source!Score
  to c: Target!Coin = condition ? new Target!GoldCoin : new Target!SilverCoin
{
  /* set common Coin details of c */
  if (c.isKindOf(Target!GoldCoin)) {
    /* set GoldCoin-specific details of c */
  } else {
    /* set SilverCoin-specific details of c */
  }
}

In general, we would extend each element of the to list with the ability to have an optional initializing expression, which would be executed during the first phase of the default ETL algorithm, before rule bodies are run.

@agarciadom agarciadom added the enhancement New feature or request label Oct 9, 2024
@agarciadom agarciadom added this to the 2.6.0 milestone Oct 9, 2024
@agarciadom agarciadom modified the milestones: 2.6.0, 2.7.0 Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant