Skip to content

Commit

Permalink
Add support to access field of a record (#74)
Browse files Browse the repository at this point in the history
Add support to access field of a record in the way .field
  • Loading branch information
sfc-gh-aramirezfuentes authored and sfc-gh-lfallasavendano committed Jan 8, 2024
1 parent 3206866 commit 31140fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Morphir/Snowpark/Backend.elm
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ mapValue value ctx =
mapIfThenElse condition thenExpr elseExpr ctx
LetDefinition _ name definition body ->
mapLetDefinition name definition body ctx
FieldFunction _ [name] ->
Constants.applySnowparkFunc "col" [(Scala.Literal (Scala.StringLit name))]
_ ->
Scala.Literal (Scala.StringLit ("Unsupported element"))

Expand Down
4 changes: 3 additions & 1 deletion src/Morphir/Snowpark/MapFunctionsMapping.elm
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,10 @@ processLambdaWithRecordBody functionExpr ctx mapValue =
Nothing
ValueIR.Lambda (TypeIR.Function _ _ returnType) (ValueIR.AsPattern _ _ _) expr ->
if isBasicType returnType then
Just [ Scala.ArgValue Nothing <| mapValue expr ctx ]
Just [ Scala.ArgValue Nothing <| mapValue expr ctx ]
else
Nothing
ValueIR.FieldFunction _ _ ->
Just [Scala.ArgValue Nothing (mapValue functionExpr ctx)]
_ ->
Nothing

0 comments on commit 31140fd

Please sign in to comment.