use of org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.ColumnMapping in project legend-pure by finos.
the class ViewProcessing method processView.
private static void processView(SetIterable<Database> dbsInHierarchy, View view, Matcher matcher, ProcessorState processorState, ModelRepository repository, ProcessorSupport processorSupport) {
DatabaseProcessor.processColumnsForTableOrView(view);
RichIterable<? extends ColumnMapping> columnMappings = view._columnMappings();
MutableMap<String, DataType> colMappingTypeByName = Maps.mutable.ofInitialCapacity(columnMappings.size());
MutableSet<RelationalOperationElement> columnMappingRootTables = Sets.mutable.empty();
for (ColumnMapping columnMapping : columnMappings) {
RelationalOperationElement columnMappingRelationalElement = columnMapping._relationalOperationElement();
String columnMappingColumnName = columnMapping._columnName();
RelationalOperationElementProcessor.processColumnExpr(columnMappingRelationalElement, view, null, Sets.mutable.empty(), matcher, processorState, repository, processorSupport);
RelationalOperationElement columnMappingRootTable = findMainTable(dbsInHierarchy, view, processorSupport, columnMappingRelationalElement);
if (columnMappingRootTable != null) {
columnMappingRootTables.add(columnMappingRootTable);
}
colMappingTypeByName.put(columnMappingColumnName, getColumnType(columnMappingRelationalElement, processorSupport, repository));
}
RelationalOperationElement mainTable = identifyMainTable(view, columnMappingRootTables);
processDynaFunctionAliases(view, mainTable, processorSupport);
processFilterMapping(view, null, mainTable, matcher, processorState, repository, processorSupport);
processGroupByMapping(view, matcher, processorState, repository, mainTable, processorSupport);
processPrimaryKeys(view, colMappingTypeByName);
setViewColumnsType(view, colMappingTypeByName);
setViewMainTableAlias(view, mainTable, processorSupport);
}
use of org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.ColumnMapping in project legend-pure by finos.
the class DatabaseUnloadUnbind method processView.
private void processView(View view, ModelRepository repository, ProcessorSupport processorSupport) {
view._schemaRemove();
this.processTableOrViewColumns(view);
view._userDefinedPrimaryKeyRemove();
RelationalMappingSpecificationUnbind.cleanRelationalMappingSpecification(view, repository, processorSupport);
for (Column column : LazyIterate.concatenate((Iterable<Column>) view._primaryKey(), (Iterable<Column>) view._columns())) {
column._typeRemove();
}
for (ColumnMapping columnMapping : view._columnMappings()) {
RelationalOperationElement columnMappingRelationalElement = columnMapping._relationalOperationElement();
RelationalOperationElementUnbind.cleanNode(columnMappingRelationalElement, repository, processorSupport);
}
}
use of org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.ColumnMapping in project legend-engine by finos.
the class HelperRelationalBuilder method findMainTable.
private static RelationalOperationElement findMainTable(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.View srcView, View view, MutableList<ColumnMapping> columnMappings) {
MutableSet<RelationalOperationElement> columnMappingRootTables = UnifiedSet.newSet();
for (ColumnMapping columnMapping : columnMappings) {
RelationalOperationElement columnMappingRelationalElement = columnMapping._relationalOperationElement();
RelationalOperationElement columnMappingRootTable = findMainTable(columnMappingRelationalElement);
if (columnMappingRootTable != null) {
columnMappingRootTables.add(columnMappingRootTable);
}
}
return identifyMainTable(srcView, view, columnMappingRootTables);
}
use of org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.ColumnMapping in project legend-pure by finos.
the class ViewProcessing method populateReferenceUsagesForView.
private static void populateReferenceUsagesForView(View view, ModelRepository repository, ProcessorSupport processorSupport) {
RichIterable<? extends ColumnMapping> columnMappings = view._columnMappings();
for (ColumnMapping columnMapping : columnMappings) {
RelationalOperationElement columnExpression = columnMapping._relationalOperationElement();
RelationalOperationElementProcessor.populateColumnExpressionReferenceUsages(columnExpression, repository, processorSupport);
}
populateFilterMappingReferenceUsages(view, repository, processorSupport);
populateGroupByMappingReferenceUsages(view, repository, processorSupport);
}
use of org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.ColumnMapping in project legend-pure by finos.
the class ViewProcessing method processDynaFunctionAliases.
private static void processDynaFunctionAliases(View view, RelationalOperationElement mainTable, ProcessorSupport processorSupport) {
RichIterable<? extends ColumnMapping> columnMappings = view._columnMappings();
columnMappings.forEach(coreInstance -> {
RelationalOperationElement roe = coreInstance._relationalOperationElement();
MutableList<JoinTreeNode> joinTreeNodes = Lists.mutable.empty();
RelationalOperationElementProcessor.collectJoinTreeNodes(joinTreeNodes, roe);
for (JoinTreeNode joinTreeNode : joinTreeNodes) {
RelationalOperationElementProcessor.processAliasForJoinTreeNode(joinTreeNode, mainTable, processorSupport);
}
});
}
Aggregations