Search in sources :

Example 1 with Schema

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Schema in project legend-engine by finos.

the class RelationalCompilerExtension method getExtraExecutionContextProcessors.

@Override
public List<Function2<ExecutionContext, CompileContext, org.finos.legend.pure.m3.coreinstance.meta.pure.runtime.ExecutionContext>> getExtraExecutionContextProcessors() {
    return Collections.singletonList((executionContext, context) -> {
        if (executionContext instanceof RelationalExecutionContext) {
            RelationalExecutionContext relationalContext = (RelationalExecutionContext) executionContext;
            MutableMap<Relation, org.finos.legend.pure.m3.coreinstance.meta.pure.functions.collection.List<Column>> fksByTable = Maps.mutable.empty();
            ListIterate.forEach(relationalContext.importDataFlowFkCols, fks -> {
                org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.Schema schema = ((org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.Database) context.pureModel.getStore(fks.table.getDb()))._schemas().detect(s -> s._name().equals(fks.table.schema));
                RichIterable<? extends NamedRelation> relations = fks.table._type.equals("Table") ? schema._tables() : fks.table._type.equals("View") ? schema._views() : null;
                Relation table = relations != null ? relations.detect(a -> a._name().equals(fks.table.table)) : null;
                RichIterable<Column> columns = ListIterate.collect(fks.columns, col -> table != null ? table._columns().select(c -> c instanceof Column).collect(c -> (Column) c).detect(c -> c._name().equals(col)) : null).select(Objects::nonNull);
                fksByTable.put(table, new Root_meta_pure_functions_collection_List_Impl("")._values(columns));
            });
            return new Root_meta_relational_runtime_RelationalExecutionContext_Impl("")._queryTimeOutInSeconds(relationalContext.queryTimeOutInSeconds)._enableConstraints(relationalContext.enableConstraints)._addDriverTablePkForProject(relationalContext.addDriverTablePkForProject)._insertDriverTablePkInTempTable(relationalContext.insertDriverTablePkInTempTable)._useTempTableAsDriver(relationalContext.useTempTableAsDriver)._preserveJoinOrder(relationalContext.preserveJoinOrder)._importDataFlow(relationalContext.importDataFlow)._importDataFlowAddFks(relationalContext.importDataFlowAddFks)._importDataFlowFksByTable(relationalContext.importDataFlowAddFks != null && relationalContext.importDataFlowAddFks ? new PureMap(fksByTable) : null)._importDataFlowImplementationCount(relationalContext.importDataFlowImplementationCount);
        }
        return null;
    });
}
Also used : PostProcessorWithParameter(org.finos.legend.pure.m3.coreinstance.meta.relational.runtime.PostProcessorWithParameter) RootRelationalInstanceSetImplementation(org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.RootRelationalInstanceSetImplementation) Multimap(org.eclipse.collections.api.multimap.Multimap) Schema(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Schema) RelationalAssociationImplementation(org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.RelationalAssociationImplementation) MutableList(org.eclipse.collections.api.list.MutableList) AggregationAwareClassMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.aggregationAware.AggregationAwareClassMapping) Maps(org.eclipse.collections.api.factory.Maps) RootRelationalClassMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.RootRelationalClassMapping) MutableSet(org.eclipse.collections.api.set.MutableSet) Handlers(org.finos.legend.engine.language.pure.compiler.toPureGraph.handlers.Handlers) RichIterable(org.eclipse.collections.api.RichIterable) Store(org.finos.legend.pure.m3.coreinstance.meta.pure.store.Store) Relation(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.Relation) Processor(org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.Processor) Tuples(org.eclipse.collections.impl.tuple.Tuples) RelationalInputData(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.mappingTest.RelationalInputData) org.finos.legend.pure.m3.coreinstance.meta.pure.mapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping) Function4(org.finos.legend.engine.shared.core.function.Function4) IntObjectToIntFunction(org.eclipse.collections.api.block.function.primitive.IntObjectToIntFunction) PostProcessor(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.postprocessor.PostProcessor) PureClientVersions(org.finos.legend.engine.protocol.pure.PureClientVersions) Objects(java.util.Objects) Procedure3(org.finos.legend.engine.shared.core.function.Procedure3) RelationalDatabaseConnection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.RelationalDatabaseConnection) org.finos.legend.pure.generated(org.finos.legend.pure.generated) List(java.util.List) ClassMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.ClassMapping) Procedure2(org.eclipse.collections.api.block.procedure.Procedure2) DatabaseInstance(org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.DatabaseInstance) EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException) org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel) InputData(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.mappingTest.InputData) PackageableElement(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement) Function(org.eclipse.collections.api.block.function.Function) AuthenticationStrategy(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.authentication.AuthenticationStrategy) Lists(org.eclipse.collections.api.factory.Lists) AssociationMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.AssociationMapping) Procedure(org.eclipse.collections.api.block.procedure.Procedure) FastList(org.eclipse.collections.impl.list.mutable.FastList) DatasourceSpecification(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.specification.DatasourceSpecification) Function3(org.eclipse.collections.api.block.function.Function3) MutableMap(org.eclipse.collections.api.map.MutableMap) HelperModelBuilder.getElementFullPath(org.finos.legend.engine.language.pure.compiler.toPureGraph.HelperModelBuilder.getElementFullPath) Function2(org.eclipse.collections.api.block.function.Function2) FunctionHandlerRegistrationInfo(org.finos.legend.engine.language.pure.compiler.toPureGraph.handlers.FunctionHandlerRegistrationInfo) RelationalAssociationMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.RelationalAssociationMapping) Database(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Database) RelationalExecutionContext(org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.executionContext.RelationalExecutionContext) PureMap(org.finos.legend.pure.runtime.java.compiled.generation.processors.support.map.PureMap) Pair(org.eclipse.collections.api.tuple.Pair) FunctionHandlerDispatchBuilderInfo(org.finos.legend.engine.language.pure.compiler.toPureGraph.handlers.FunctionHandlerDispatchBuilderInfo) ListIterate(org.eclipse.collections.impl.utility.ListIterate) AggregationAwareSetImplementation(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.aggregationAware.AggregationAwareSetImplementation) ValueSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification) EmbeddedRelationalInstanceSetImplementation(org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.EmbeddedRelationalInstanceSetImplementation) Connection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.Connection) ImmutableList(org.eclipse.collections.api.list.ImmutableList) ExecutionContext(org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.executionContext.ExecutionContext) AggregateSetImplementationContainer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.aggregationAware.AggregateSetImplementationContainer) MapperPostProcessor(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.postprocessor.MapperPostProcessor) FunctionExpressionBuilderRegistrationInfo(org.finos.legend.engine.language.pure.compiler.toPureGraph.handlers.FunctionExpressionBuilderRegistrationInfo) NamedRelation(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.NamedRelation) Collections(java.util.Collections) org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel) PureMap(org.finos.legend.pure.runtime.java.compiled.generation.processors.support.map.PureMap) Relation(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.Relation) NamedRelation(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.NamedRelation) RelationalExecutionContext(org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.executionContext.RelationalExecutionContext) Objects(java.util.Objects) MutableList(org.eclipse.collections.api.list.MutableList) List(java.util.List) FastList(org.eclipse.collections.impl.list.mutable.FastList) ImmutableList(org.eclipse.collections.api.list.ImmutableList)

Example 2 with Schema

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Schema in project legend-engine by finos.

the class RelationalCompilerExtension method getExtraStoreStatBuilders.

@Override
public List<Procedure2<PackageableElement, MutableMap<String, String>>> getExtraStoreStatBuilders() {
    return Collections.singletonList((element, stats) -> {
        if (element instanceof Database) {
            Database db = (Database) element;
            stats.put("type", "Database");
            stats.put("tables", "" + ListIterate.injectInto(0, db.schemas, (IntObjectToIntFunction<Schema>) (a, b) -> a + b.tables.size()));
            stats.put("views", "" + ListIterate.injectInto(0, db.schemas, (IntObjectToIntFunction<Schema>) (a, b) -> a + b.views.size()));
            stats.put("joins", "" + db.joins.size());
            stats.put("filters", "" + db.filters.size());
        }
    });
}
Also used : PostProcessorWithParameter(org.finos.legend.pure.m3.coreinstance.meta.relational.runtime.PostProcessorWithParameter) RootRelationalInstanceSetImplementation(org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.RootRelationalInstanceSetImplementation) Multimap(org.eclipse.collections.api.multimap.Multimap) Schema(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Schema) RelationalAssociationImplementation(org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.RelationalAssociationImplementation) MutableList(org.eclipse.collections.api.list.MutableList) AggregationAwareClassMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.aggregationAware.AggregationAwareClassMapping) Maps(org.eclipse.collections.api.factory.Maps) RootRelationalClassMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.RootRelationalClassMapping) MutableSet(org.eclipse.collections.api.set.MutableSet) Handlers(org.finos.legend.engine.language.pure.compiler.toPureGraph.handlers.Handlers) RichIterable(org.eclipse.collections.api.RichIterable) Store(org.finos.legend.pure.m3.coreinstance.meta.pure.store.Store) Relation(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.Relation) Processor(org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.Processor) Tuples(org.eclipse.collections.impl.tuple.Tuples) RelationalInputData(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.mappingTest.RelationalInputData) org.finos.legend.pure.m3.coreinstance.meta.pure.mapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping) Function4(org.finos.legend.engine.shared.core.function.Function4) IntObjectToIntFunction(org.eclipse.collections.api.block.function.primitive.IntObjectToIntFunction) PostProcessor(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.postprocessor.PostProcessor) PureClientVersions(org.finos.legend.engine.protocol.pure.PureClientVersions) Objects(java.util.Objects) Procedure3(org.finos.legend.engine.shared.core.function.Procedure3) RelationalDatabaseConnection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.RelationalDatabaseConnection) org.finos.legend.pure.generated(org.finos.legend.pure.generated) List(java.util.List) ClassMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.ClassMapping) Procedure2(org.eclipse.collections.api.block.procedure.Procedure2) DatabaseInstance(org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.DatabaseInstance) EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException) org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel) InputData(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.mappingTest.InputData) PackageableElement(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement) Function(org.eclipse.collections.api.block.function.Function) AuthenticationStrategy(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.authentication.AuthenticationStrategy) Lists(org.eclipse.collections.api.factory.Lists) AssociationMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.AssociationMapping) Procedure(org.eclipse.collections.api.block.procedure.Procedure) FastList(org.eclipse.collections.impl.list.mutable.FastList) DatasourceSpecification(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.specification.DatasourceSpecification) Function3(org.eclipse.collections.api.block.function.Function3) MutableMap(org.eclipse.collections.api.map.MutableMap) HelperModelBuilder.getElementFullPath(org.finos.legend.engine.language.pure.compiler.toPureGraph.HelperModelBuilder.getElementFullPath) Function2(org.eclipse.collections.api.block.function.Function2) FunctionHandlerRegistrationInfo(org.finos.legend.engine.language.pure.compiler.toPureGraph.handlers.FunctionHandlerRegistrationInfo) RelationalAssociationMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.RelationalAssociationMapping) Database(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Database) RelationalExecutionContext(org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.executionContext.RelationalExecutionContext) PureMap(org.finos.legend.pure.runtime.java.compiled.generation.processors.support.map.PureMap) Pair(org.eclipse.collections.api.tuple.Pair) FunctionHandlerDispatchBuilderInfo(org.finos.legend.engine.language.pure.compiler.toPureGraph.handlers.FunctionHandlerDispatchBuilderInfo) ListIterate(org.eclipse.collections.impl.utility.ListIterate) AggregationAwareSetImplementation(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.aggregationAware.AggregationAwareSetImplementation) ValueSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification) EmbeddedRelationalInstanceSetImplementation(org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.EmbeddedRelationalInstanceSetImplementation) Connection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.Connection) ImmutableList(org.eclipse.collections.api.list.ImmutableList) ExecutionContext(org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.executionContext.ExecutionContext) AggregateSetImplementationContainer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.aggregationAware.AggregateSetImplementationContainer) MapperPostProcessor(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.postprocessor.MapperPostProcessor) FunctionExpressionBuilderRegistrationInfo(org.finos.legend.engine.language.pure.compiler.toPureGraph.handlers.FunctionExpressionBuilderRegistrationInfo) NamedRelation(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.NamedRelation) Collections(java.util.Collections) Schema(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Schema) Database(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Database)

Example 3 with Schema

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Schema in project legend-engine by finos.

the class RelationalParseTreeWalker method generateTableAlias.

private TablePtr generateTableAlias(ScopeInfo scopeInfo, SourceInformation sourceInformation) {
    Token schema = scopeInfo.schemaToken;
    Token alias = scopeInfo.tableAliasToken;
    if (alias == null) {
        if (schema == null) {
            throw new EngineException("Missing table or alias" + (scopeInfo.columnToken == null ? "" : (" for column '" + scopeInfo.columnToken.getText() + "'")), sourceInformation, EngineErrorType.PARSER);
        }
        alias = schema;
        schema = null;
    }
    TablePtr tablePtr = new TablePtr();
    tablePtr._type = "Table";
    String database = scopeInfo.database;
    tablePtr.database = database;
    tablePtr.mainTableDb = database;
    // NOTE: this is a minor inference for the schema name, we might consider moving this to the compiler instead
    tablePtr.schema = schema != null ? schema.getText() : "default";
    tablePtr.table = alias.getText();
    tablePtr.sourceInformation = schema == null ? this.walkerSourceInformation.getSourceInformation(alias) : this.walkerSourceInformation.getSourceInformation(schema, alias);
    return tablePtr;
}
Also used : EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException) Token(org.antlr.v4.runtime.Token) TablePtr(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.TablePtr)

Example 4 with Schema

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Schema in project legend-engine by finos.

the class RelationalParseTreeWalker method visitDatabase.

private Database visitDatabase(RelationalParserGrammar.DatabaseContext ctx) {
    Database database = new Database();
    database.name = PureGrammarParserUtility.fromIdentifier(ctx.qualifiedName().identifier());
    database._package = ctx.qualifiedName().packagePath() == null ? "" : PureGrammarParserUtility.fromPath(ctx.qualifiedName().packagePath().identifier());
    database.sourceInformation = this.walkerSourceInformation.getSourceInformation(ctx);
    ScopeInfo scopeInfo = ScopeInfo.Builder.newInstance().withDatabase(PureGrammarParserUtility.fromQualifiedName(ctx.qualifiedName().packagePath() == null ? Collections.emptyList() : ctx.qualifiedName().packagePath().identifier(), ctx.qualifiedName().identifier())).build();
    database.includedStores = ListIterate.collect(ctx.include(), includeContext -> PureGrammarParserUtility.fromQualifiedName(includeContext.qualifiedName().packagePath() == null ? Collections.emptyList() : includeContext.qualifiedName().packagePath().identifier(), includeContext.qualifiedName().identifier()));
    database.schemas = ListIterate.collect(ctx.schema(), schemaCtx -> this.visitSchema(schemaCtx, scopeInfo));
    // NOTE: if tables and views are defined without a schema, create a default schema to hold these
    List<Table> tables = ListIterate.collect(ctx.table(), this::visitTable);
    List<View> views = ListIterate.collect(ctx.view(), viewCtx -> this.visitView(viewCtx, scopeInfo));
    if (!tables.isEmpty() || !views.isEmpty()) {
        Schema schema = new Schema();
        schema.sourceInformation = database.sourceInformation;
        schema.name = "default";
        schema.tables = tables;
        schema.views = views;
        database.schemas.add(schema);
    }
    database.joins = ListIterate.collect(ctx.join(), joinCtx -> this.visitJoin(joinCtx, scopeInfo));
    MutableList<Filter> filters = ListIterate.collect(ctx.filter(), filterCtx -> this.visitFilter(filterCtx, scopeInfo));
    if (!ctx.multiGrainFilter().isEmpty()) {
        filters.addAll(ListIterate.collect(ctx.multiGrainFilter(), filterCtx -> this.visitMultiGrainFilter(filterCtx, scopeInfo)));
    }
    database.filters = filters;
    return database;
}
Also used : Milestoning(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.milestoning.Milestoning) Decimal(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Decimal) Interval(org.antlr.v4.runtime.misc.Interval) ColumnMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.ColumnMapping) EngineErrorType(org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType) Token(org.antlr.v4.runtime.Token) Schema(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Schema) FilterPointer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.FilterPointer) SemiStructured(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.SemiStructured) MilestoningSpecificationSourceCode(org.finos.legend.engine.language.pure.grammar.from.milestoning.MilestoningSpecificationSourceCode) MutableList(org.eclipse.collections.api.list.MutableList) LiteralList(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.LiteralList) RelationalOperationElement(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.RelationalOperationElement) RootRelationalClassMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.RootRelationalClassMapping) PropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.PropertyMapping) ElementWithJoins(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.ElementWithJoins) Multiplicity(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Multiplicity) Date(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Date) DefaultCodeSection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.DefaultCodeSection) Table(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Table) Numeric(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Numeric) LocalMappingPropertyInfo(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.LocalMappingPropertyInfo) SourceInformation(org.finos.legend.engine.protocol.pure.v1.model.SourceInformation) JoinPointer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.JoinPointer) Collectors(java.util.stream.Collectors) SmallInt(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.SmallInt) Other(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Other) DynaFunc(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.DynaFunc) List(java.util.List) Char(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Char) EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException) ParserRuleContext(org.antlr.v4.runtime.ParserRuleContext) PackageableElement(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement) EmbeddedRelationalPropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.EmbeddedRelationalPropertyMapping) InlineEmbeddedPropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.InlineEmbeddedPropertyMapping) FastList(org.eclipse.collections.impl.list.mutable.FastList) ArrayList(java.util.ArrayList) BindingTransformer(org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.BindingTransformer) VarChar(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.VarChar) RelationalAssociationMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.RelationalAssociationMapping) BigInt(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.BigInt) Bit(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Bit) Real(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Real) TablePtr(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.TablePtr) Database(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Database) MultiGrainFilter(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.MultiGrainFilter) Binary(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Binary) View(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.View) Join(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Join) Sets(org.eclipse.collections.api.factory.Sets) Timestamp(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Timestamp) TinyInt(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.TinyInt) RelationalParserGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.RelationalParserGrammar) Filter(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Filter) ListIterate(org.eclipse.collections.impl.utility.ListIterate) OtherwiseEmbeddedRelationalPropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.OtherwiseEmbeddedRelationalPropertyMapping) Consumer(java.util.function.Consumer) PropertyPointer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.PropertyPointer) FilterMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.FilterMapping) RelationalClassMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.RelationalClassMapping) RelationalPropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.RelationalPropertyMapping) ImmutableSet(org.eclipse.collections.api.set.ImmutableSet) TableAliasColumn(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.TableAliasColumn) Varbinary(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Varbinary) Literal(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.Literal) Collections(java.util.Collections) Column(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Column) Table(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Table) MultiGrainFilter(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.MultiGrainFilter) Filter(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Filter) Schema(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Schema) Database(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Database) View(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.View)

Example 5 with Schema

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Schema in project legend-engine by finos.

the class RelationalParseTreeWalker method visitSchema.

// ----------------------------------------------- SCHEMA -----------------------------------------------
public Schema visitSchema(RelationalParserGrammar.SchemaContext ctx, ScopeInfo scopeInfo) {
    Schema schema = new Schema();
    schema.sourceInformation = this.walkerSourceInformation.getSourceInformation(ctx);
    schema.name = PureGrammarParserUtility.fromIdentifier(ctx.identifier());
    schema.tables = ListIterate.collect(ctx.table(), this::visitTable);
    schema.views = ListIterate.collect(ctx.view(), viewCtx -> this.visitView(viewCtx, ScopeInfo.Builder.newInstance(scopeInfo).withSchemaToken(ctx.identifier().getStart()).build()));
    return schema;
}
Also used : Milestoning(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.milestoning.Milestoning) Decimal(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Decimal) Interval(org.antlr.v4.runtime.misc.Interval) ColumnMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.ColumnMapping) EngineErrorType(org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType) Token(org.antlr.v4.runtime.Token) Schema(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Schema) FilterPointer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.FilterPointer) SemiStructured(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.SemiStructured) MilestoningSpecificationSourceCode(org.finos.legend.engine.language.pure.grammar.from.milestoning.MilestoningSpecificationSourceCode) MutableList(org.eclipse.collections.api.list.MutableList) LiteralList(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.LiteralList) RelationalOperationElement(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.RelationalOperationElement) RootRelationalClassMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.RootRelationalClassMapping) PropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.PropertyMapping) ElementWithJoins(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.ElementWithJoins) Multiplicity(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Multiplicity) Date(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Date) DefaultCodeSection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.DefaultCodeSection) Table(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Table) Numeric(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Numeric) LocalMappingPropertyInfo(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.LocalMappingPropertyInfo) SourceInformation(org.finos.legend.engine.protocol.pure.v1.model.SourceInformation) JoinPointer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.JoinPointer) Collectors(java.util.stream.Collectors) SmallInt(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.SmallInt) Other(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Other) DynaFunc(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.DynaFunc) List(java.util.List) Char(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Char) EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException) ParserRuleContext(org.antlr.v4.runtime.ParserRuleContext) PackageableElement(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement) EmbeddedRelationalPropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.EmbeddedRelationalPropertyMapping) InlineEmbeddedPropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.InlineEmbeddedPropertyMapping) FastList(org.eclipse.collections.impl.list.mutable.FastList) ArrayList(java.util.ArrayList) BindingTransformer(org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.BindingTransformer) VarChar(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.VarChar) RelationalAssociationMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.RelationalAssociationMapping) BigInt(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.BigInt) Bit(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Bit) Real(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Real) TablePtr(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.TablePtr) Database(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Database) MultiGrainFilter(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.MultiGrainFilter) Binary(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Binary) View(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.View) Join(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Join) Sets(org.eclipse.collections.api.factory.Sets) Timestamp(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Timestamp) TinyInt(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.TinyInt) RelationalParserGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.RelationalParserGrammar) Filter(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Filter) ListIterate(org.eclipse.collections.impl.utility.ListIterate) OtherwiseEmbeddedRelationalPropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.OtherwiseEmbeddedRelationalPropertyMapping) Consumer(java.util.function.Consumer) PropertyPointer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.PropertyPointer) FilterMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.FilterMapping) RelationalClassMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.RelationalClassMapping) RelationalPropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.RelationalPropertyMapping) ImmutableSet(org.eclipse.collections.api.set.ImmutableSet) TableAliasColumn(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.TableAliasColumn) Varbinary(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Varbinary) Literal(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.Literal) Collections(java.util.Collections) Column(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Column) Schema(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Schema)

Aggregations

PureModelContextData (org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData)24 Test (org.junit.Test)17 List (java.util.List)10 MutableList (org.eclipse.collections.api.list.MutableList)10 PureModel (org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel)10 FastList (org.eclipse.collections.impl.list.mutable.FastList)9 Schema (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Schema)9 ListIterate (org.eclipse.collections.impl.utility.ListIterate)8 Database (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Database)8 EngineException (org.finos.legend.engine.shared.core.operational.errorManagement.EngineException)8 SchemaToModelGenerationTest (org.finos.legend.engine.external.shared.format.model.test.SchemaToModelGenerationTest)6 SourceInformation (org.finos.legend.engine.protocol.pure.v1.model.SourceInformation)6 ApiOperation (io.swagger.annotations.ApiOperation)5 Collections (java.util.Collections)5 Pair (org.eclipse.collections.api.tuple.Pair)5 ExternalFormatExtension (org.finos.legend.engine.external.shared.format.model.ExternalFormatExtension)5 PackageableElement (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement)5 RelationalDatabaseConnection (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.RelationalDatabaseConnection)5 RelationalAssociationMapping (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.RelationalAssociationMapping)5 RootRelationalClassMapping (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.RootRelationalClassMapping)5