From 5a729a34af96611dd1c7aa594ca16c431f44588a Mon Sep 17 00:00:00 2001 From: "Fine, Adam [Engineering]" Date: Wed, 20 Sep 2023 08:59:02 -0400 Subject: [PATCH] add support for pushing down sql enum transforms --- .../language/pure/compiler/toPureGraph/handlers/Handlers.java | 2 +- .../resources/core/pure/router/routing/router_routing.pure | 3 ++- .../core_relational/relational/contract/storeContract.pure | 2 +- .../relational/graphFetch/relationalGraphFetch.pure | 2 +- .../core_relational/relational/relationalMappingExecution.pure | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/legend-engine-core/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/handlers/Handlers.java b/legend-engine-core/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/handlers/Handlers.java index 330193953bb..124d60031c5 100644 --- a/legend-engine-core/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/handlers/Handlers.java +++ b/legend-engine-core/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/handlers/Handlers.java @@ -628,7 +628,7 @@ public Handlers(PureModel pureModel) register(m(h("meta::pure::mutation::save_T_MANY__RootGraphFetchTree_1__Mapping_1__Runtime_1__T_MANY_", false, ps -> res(ps.get(0)._genericType(), "zeroMany"), ps -> true))); register("meta::pure::tds::extensions::firstNotNull_T_MANY__T_$0_1$_", false, ps -> res(ps.get(0)._genericType(), "zeroOne")); - + register("meta::pure::functions::hash::hash_String_1__HashType_1__String_1_", true, ps -> res("String","one")); // Extensions diff --git a/legend-engine-pure/legend-engine-pure-code/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/router/routing/router_routing.pure b/legend-engine-pure/legend-engine-pure-code/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/router/routing/router_routing.pure index fb324d44454..2f8e9cdc68e 100644 --- a/legend-engine-pure/legend-engine-pure-code/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/router/routing/router_routing.pure +++ b/legend-engine-pure/legend-engine-pure-code/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/router/routing/router_routing.pure @@ -45,6 +45,7 @@ Class meta::pure::router::routing::RoutingState value : Any[0..1]; executionContext: ExecutionContext[1] = ^ExecutionContext(); graphFetchFlow : Boolean[0..1]; + executionContext: ExecutionContext[1] = ^ExecutionContext(); } Class meta::pure::router::routing::PropertyMap @@ -141,7 +142,7 @@ function <> meta::pure::router::routing::routeValueSpecification if($i.values->size() == 1 && $i.values->at(0)->instanceOf(RelationStoreAccessor), | $state.routingStrategy.processRelationStoreAccessor($i.values->at(0)->cast(@RelationStoreAccessor), $i, $state, $executionContext, $debug);, | $state - ); + ); ), pair( |$i->isOneClass() || ($i.values->isEmpty() && $i.multiplicity == PureOne && $i.genericType.rawType->isNotEmpty() && $i.genericType.rawType->toOne()->instanceOf(Class)), diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/contract/storeContract.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/contract/storeContract.pure index ba6322a316e..419acfd11b7 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/contract/storeContract.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/contract/storeContract.pure @@ -246,7 +246,7 @@ function meta::relational::contract::planExecution(sq:meta::pure::mapping::Store ->generateExecutionNodeForPostProcessedResult($sq, $store, $ext, $m->toOne(), $storeRuntime, $exeCtx, $debug, $extensions); ); - ); + } function meta::relational::contract::postProcessorsMatch(postProcessors1: meta::pure::alloy::connections::PostProcessor[*], postProcessors2: meta::pure::alloy::connections::PostProcessor[*]): Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/graphFetch/relationalGraphFetch.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/graphFetch/relationalGraphFetch.pure index f06904913d3..354a3659be1 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/graphFetch/relationalGraphFetch.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/graphFetch/relationalGraphFetch.pure @@ -749,7 +749,7 @@ function <> meta::relational::graphFetch::executionPlan::generat }); } -function <> meta::relational::graphFetch::executionPlan::buildBaseQueryForChild(setImpls: RelationalInstanceSetImplementation[*], pureToSqlState: State[1], mc: TemporalMilestoningContext[0..1], extensions: Extension[*], debug: DebugContext[1]):SelectWithCursor[1] +function <> meta::relational::graphFetch::executionPlan::buildBaseQueryForChild(setImpls: RelationalInstanceSetImplementation[*], pureToSqlState: State[1], mc: TemporalMilestoningContext[0..1],exeCtx:ExecutionContext[1], extensions: Extension[*], debug: DebugContext[1]):SelectWithCursor[1] { let isQualified = $propTree.property->instanceOf(QualifiedProperty); let pureToSqlState = defaultState($mapping, $inScopeVars, $exeCtx, $extensions); diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/relationalMappingExecution.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/relationalMappingExecution.pure index f1090cdb1c9..f60f2444280 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/relationalMappingExecution.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/relationalMappingExecution.pure @@ -78,7 +78,7 @@ function meta::relational::mapping::generateInstantiationExecutionNode(sq:meta:: name = $p.first, type = $p.second.type->cast(@meta::pure::metamodel::type::DataType), documentation = $p.second.documentation, - enumMappingId = if($exeCtx->contextHasFlag(meta::pure::executionPlan::features::Feature.PUSH_DOWN_ENUM_TRANSFORM),|[] ,| $p.second.propertyMapping->match([r:RelationalPropertyMapping[0..1] | $r.transformer->cast(@EnumerationMapping).name, p:PropertyMapping[0..1] | []])), + enumMappingId = if($exeCtx->contextHasFlag(meta::pure::executionPlan::features::Feature.PUSH_DOWN_ENUM_TRANSFORM),|[] ,| $p.second.propertyMapping->match([r:RelationalPropertyMapping[0..1] | $r.transformer->cast(@EnumerationMapping).name, p:PropertyMapping[0..1] | []])), offset = $paths->indexOf($p), sourceDataType = if($p.second.relationalType->isNotEmpty(), | $p.second.relationalType,