morphir-elm
morphir-elm copied to clipboard
bug: inlineLetDef inlines definitions in the wrong place
I created the branch https://github.com/CodethinkLabs/morphir-elm/tree/jonathanmaw/inline-letdef-ordering which adds an example that highlights this.
From an elm function of the form:
testLetDef : List AntiqueSubset -> List AntiqueSubset
testLetDef source =
let
exact1 = 5.0
exact2 = 7.0
max = 20.0
min = 10.0
not = 15.0
in
source
|> List.filter
(\antique ->
(antique.ageOfItem <= max) && (antique.ageOfItem >= min) && (antique.ageOfItem /= not) || (antique.ageOfItem == exact1) || (antique.ageOfItem == exact2)
)
The following Spark code is generated
def testLetDef(
source: org.apache.spark.sql.DataFrame
): org.apache.spark.sql.DataFrame =
source.filter((((org.apache.spark.sql.functions.col("ageOfItem")) <= (20)) and (((org.apache.spark.sql.functions.col("ageOfItem")) >= (7)) and ((org.apache.spark.sql.functions.col("ageOfItem")) =!= (5)))) or (((org.apache.spark.sql.functions.col("ageOfItem")) === (15)) or ((org.apache.spark.sql.functions.col("ageOfItem")) === (10))))