From 71290aea6436cd369afb7c8daca24a81a2bbe5e0 Mon Sep 17 00:00:00 2001 From: AttilaMihaly Date: Fri, 6 May 2022 15:39:26 +0000 Subject: [PATCH 1/2] Initial version of Spark mapping document --- docs/spark-backend/design.md | 64 ++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 docs/spark-backend/design.md diff --git a/docs/spark-backend/design.md b/docs/spark-backend/design.md new file mode 100644 index 000000000..6783ec9c8 --- /dev/null +++ b/docs/spark-backend/design.md @@ -0,0 +1,64 @@ +# Morphir to Spark mapping + +To understand how the Morphir to Apache Spark mapping works let's begin with an example Morphir domain model and business logic that we might want to transpile to Spark. We present the Morphir logic using Elm syntax to make it easy to read: + +```elm +type alias RecordA = + { number1 : Int + , number2 : Int + } + +type alias RecordB = + { sum : Int + , product : Int + , ratio : Float + } + + +job : List RecordA -> List RecordB +job input = + input + |> List.filter (\a -> a.field2 < 100) + |> List.map + (\a -> + { sum = a.number1 + a.number2 + , product = a.number1 * a.number2 + , ratio = a.number1 / a.number2 + } + ) +``` + +The above is a representative example of the base functionality. There are a few constraints that we put on the Elm code to make it possible to translate to Spark initially (later on we might gradually lift those constraints by automatically transforming the logic behind the scenes). Here are the initial restrictions: + +- Functions need to get a list of records as input and return a list of records, so that we can directly map to Spark jobs taking a DataSet and returning a DataSet +- The record types in the input and output need to be completely flat and use only built-in SDK types or be enumerations (custom types with only no-argument constructors) +- The input value in the function can only be passed through the following collection operations: + - [List.filter](https://package.elm-lang.org/packages/elm/core/latest/List#filter) to filter the data set (corresponds to a WHERE clause in SQL) + - [List.map](https://package.elm-lang.org/packages/elm/core/latest/List#map) to trasform each input row to an output row (corresponds to the SELECT clause in SQL) +- Field expressions can: + - use any combination of operations from the [Morphir SDK](https://package.elm-lang.org/packages/elm/core/latest/) as long as every intermediary result within the expression is a simple type + - include `if-then-else` expressions + +## Supported Field Types + +- [Int](https://package.elm-lang.org/packages/elm/core/latest/Basics#Int) +- [Float](https://package.elm-lang.org/packages/elm/core/latest/Basics#Float) +- [Bool](https://package.elm-lang.org/packages/elm/core/latest/Basics#Bool) +- [String](https://package.elm-lang.org/packages/elm/core/latest/String#String) +- [Maybe](https://package.elm-lang.org/packages/elm/core/latest/Maybe#Maybe) + + +## Supported Field Operations + +- [Basics](https://package.elm-lang.org/packages/elm/core/latest/Basics): + - All number operations + - All comparison operations + - All boolean operations +- [String](https://package.elm-lang.org/packages/elm/core/latest/String) + - All operations + +## Supported DataSet Operations + +- [List.filter](https://package.elm-lang.org/packages/elm/core/latest/List#filter) +- [List.map](https://package.elm-lang.org/packages/elm/core/latest/List#map) + From 47461cf75e74edf28826ac6eee9facff7004f96f Mon Sep 17 00:00:00 2001 From: Attila Mihaly Date: Mon, 9 May 2022 17:15:51 +0200 Subject: [PATCH 2/2] Remove file that makes docusaurus fail. --- docs/presentations/UK_Meetup.md | 48 --------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 docs/presentations/UK_Meetup.md diff --git a/docs/presentations/UK_Meetup.md b/docs/presentations/UK_Meetup.md deleted file mode 100644 index e99f5e7a5..000000000 --- a/docs/presentations/UK_Meetup.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -marp: true -theme: default ---- - -# An introduction to Morphir - ---- - -# What is Morphir? - -* **A unified language for business and technology** - - Business and technology speaking the same language -* We already have ***methodologies*** - - UML (Unified Modeling Language) - - DDD (Domain-driven Design) - - _for humans only_ -* Morphir is a ***technology*** - - _for humans and machines_ - ---- - -# What does Morphir do? - -* **Turns business logic into portable data** so that you can - * **Translate it** _- to move between technologies effortlessly as they evolve_ - * **Visualize it** _- to unhide it from your business users_ - * **Share it** _- across organziations for consistent interpretation_ - * **and do much more ...** - - like the Internet that simply _“connects computers”_ - - it enables innovation that has a profound impact on software development - - ---- - -# Present the business problem - ---- - -# Solve it - ---- - -# Other opportunities that opened up - ---- - -# Tech stuff \ No newline at end of file