diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PureModel.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PureModel.java index 3692204884c..f9ab85f79eb 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PureModel.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PureModel.java @@ -939,6 +939,10 @@ public Type getType_safe(String fullPath) // Search for system types in the Pure graph type = tryGetFromMetadataAccessor(fullPath, MetadataAccessor::getClass, MetadataAccessor::getEnumeration, MetadataAccessor::getPrimitiveType, MetadataAccessor::getMeasure, MetadataAccessor::getUnit); + if (type == null) + { + type = tryGetUnitByLegacyId(fullPath); + } if (type != null) { this.immutables.add(fullPathWithPrefix); @@ -952,6 +956,25 @@ public Type getType_safe(String fullPath) return type; } + private Unit tryGetUnitByLegacyId(String legacyId) + { + int unitDelimiterIndex = legacyId.lastIndexOf('~'); + if (unitDelimiterIndex != -1) + { + String measurePath = legacyId.substring(0, unitDelimiterIndex); + Measure measure = tryGetFromMetadataAccessor(measurePath, MetadataAccessor::getMeasure); + if (measure != null) + { + String unitName = legacyId.substring(unitDelimiterIndex + 1); + Unit canonicalUnit = measure._canonicalUnit(); + return ((canonicalUnit != null) && unitName.equals(canonicalUnit._name())) ? + canonicalUnit : + measure._nonCanonicalUnits().detect(ncu -> unitName.equals(ncu._name())); + } + } + return null; + } + public org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class getClass(String fullPath) { return this.getClass(fullPath, SourceInformation.getUnknownSourceInformation()); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-compiled-functions-relation/src/test/java/org/finos/legend/pure/runtime/java/extension/relation/compiled/pure/TestFunctionTester.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-compiled-functions-relation/src/test/java/org/finos/legend/pure/runtime/java/extension/relation/compiled/pure/TestFunctionTester.java index 9ee8ee4cee0..01191305b2b 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-compiled-functions-relation/src/test/java/org/finos/legend/pure/runtime/java/extension/relation/compiled/pure/TestFunctionTester.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-compiled-functions-relation/src/test/java/org/finos/legend/pure/runtime/java/extension/relation/compiled/pure/TestFunctionTester.java @@ -14,12 +14,10 @@ package org.finos.legend.pure.runtime.java.extension.relation.compiled.pure; -import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.execution.FunctionExecution; import org.finos.legend.pure.m3.tests.function.base.PureExpressionTest; import org.finos.legend.pure.runtime.java.compiled.execution.FunctionExecutionCompiledBuilder; import org.junit.After; -import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -59,16 +57,7 @@ public void sortOnTdsWithVariant() " 5, \"[13,14,15]\"\n" + " #->extend(~reversed:x | $x.payload->toMany(@Integer)->reverse()->toVariant()));\n" + "}"); - try - { - this.execute("test():Any[*]"); - Assert.fail("Error thrown when executing test function"); - } - catch (PureExecutionException e) - { - // metadata fails... - Assert.assertTrue(e.getMessage().contains(" of type meta::pure::metamodel::type::FunctionType does not exist")); - } + execute("test():Any[*]"); } @Test diff --git a/pom.xml b/pom.xml index 808348dac3b..393672bc5a2 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ - 5.76.1 + 5.78.0 0.33.0 13.2.0 0.14.0