Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@

<properties>
<!-- Legend -->
<legend.pure.version>5.76.1</legend.pure.version>
<legend.pure.version>5.78.0</legend.pure.version>
<legend.shared.version>0.33.0</legend.shared.version>
<legend.web-application.version>13.2.0</legend.web-application.version>
<legend.pylegend.version>0.14.0</legend.pylegend.version>
Expand Down
Loading