Skip to content

Commit

Permalink
Add resolver for DataQualityValidation element (#2946)
Browse files Browse the repository at this point in the history
* Add resolver for DataQualityValidation element
  • Loading branch information
keenkeystrokes authored Jul 5, 2024
1 parent 4fbe09b commit c03e69a
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ public enum PackageableElementType
DIAGRAM,
FILE_GENERATION,
DATA,
QUERYPOSTPROCESSOR
QUERYPOSTPROCESSOR,
DATA_QUALITY_VALIDATION
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
<scope>runtime</scope>
</dependency>
<!-- dataquality -->
<dependency>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-protocol</artifactId>
</dependency>
<dependency>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-protocol-pure</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public MutableList<String> group()
return org.eclipse.collections.impl.factory.Lists.mutable.with("PackageableElement", "DataQualityValidation");
}

static final ConcurrentHashMap<String, Root_meta_external_dataquality_DataQuality> dataQualityIndex = new ConcurrentHashMap<>();
static final ConcurrentHashMap<String, Root_meta_external_dataquality_DataQuality<Object>> dataQualityIndex = new ConcurrentHashMap<>();

@Override
public CompilerExtension build()
Expand Down Expand Up @@ -106,11 +106,7 @@ public Iterable<? extends Processor<?>> getExtraProcessors()
},
(dataquality, compileContext) ->
{

},
(dataquality, compileContext) ->
{
Root_meta_external_dataquality_DataQuality metamodel = dataQualityIndex.get(compileContext.pureModel.buildPackageString(dataquality._package, dataquality.name));
Root_meta_external_dataquality_DataQuality<Object> metamodel = dataQualityIndex.get(compileContext.pureModel.buildPackageString(dataquality._package, dataquality.name));
metamodel._context(buildDataQualityExecutionContext(dataquality, compileContext))
._filter(getFilterLambda(dataquality, compileContext))
._validationTree(buildRootGraphFetchTree(dataquality.dataQualityRootGraphFetchTree, compileContext, compileContext.pureModel.getClass(dataquality.dataQualityRootGraphFetchTree._class), null, new ProcessingContext("DataQuality")));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2020 Goldman Sachs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package org.finos.legend.engine.language.pure.compiler.toPureGraph;

import org.eclipse.collections.impl.utility.ListIterate;
import org.finos.legend.engine.protocol.pure.v1.model.SourceInformation;
import org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType;
import org.finos.legend.engine.shared.core.operational.Assert;
import org.finos.legend.pure.generated.Root_meta_external_dataquality_DataQuality;

import java.util.Objects;

public class HelperDataQualityBuilder
{
private static DataQualityCompilerExtension getDataQualityCompilerExtension(CompileContext context)
{
return Objects.requireNonNull(ListIterate.selectInstancesOf(context.getCompilerExtensions().getExtensions(), DataQualityCompilerExtension.class).getAny(), "DataQuality extension is not in scope");
}

public static Root_meta_external_dataquality_DataQuality<Object> getDataQuality(String fullPath, SourceInformation sourceInformation, CompileContext context)
{
Root_meta_external_dataquality_DataQuality<Object> dataQuality = DataQualityCompilerExtension.dataQualityIndex.get(fullPath);
Assert.assertTrue(dataQuality != null, () -> "Can't find dataquality '" + fullPath + "'", sourceInformation, EngineErrorType.COMPILATION);
return dataQuality;
}

public static Root_meta_external_dataquality_DataQuality<Object> resolveDataQualityValidation(String fullPath, SourceInformation sourceInformation, CompileContext context)
{
return context.resolve(fullPath, sourceInformation, path -> getDataQuality(path, sourceInformation, context));
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function meta::external::dataquality::executeDataQualityValidation(dataquality:m
let enrichedTree = $dataquality.validationTree->ensureFunctionRequirementsForDataQuality($dataquality.validationTree.constraints, $dataquality.validationTree.class, [], true)->cast(@RootGraphFetchTree<Any>);

// 2. build query
let getAll = $dataquality.validationTree.class->createGetAll();
let getAll = $dataquality.validationTree.class->createGetAllParameterized();
let getExpr = if ($dataquality.filter->isNotEmpty(),
| $dataquality.validationTree.class->generateFilterQuery($getAll, $dataquality.filter->toOne());,
| $getAll);
Expand Down

0 comments on commit c03e69a

Please sign in to comment.