diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-pure/src/main/resources/core_relational_snowflake/relational/sqlQueryToString/snowflakeExtension.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-pure/src/main/resources/core_relational_snowflake/relational/sqlQueryToString/snowflakeExtension.pure index ae11590bcd6..f2916be0a9d 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-pure/src/main/resources/core_relational_snowflake/relational/sqlQueryToString/snowflakeExtension.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-pure/src/main/resources/core_relational_snowflake/relational/sqlQueryToString/snowflakeExtension.pure @@ -51,7 +51,6 @@ function <> meta::relational::functions::sqlQueryToString::snowf windowColumnProcessor = processWindowColumn_WindowColumn_1__SqlGenerationContext_1__String_1_, semiStructuredElementProcessor = processSemiStructuredElementForSnowflake_RelationalOperationElement_1__SqlGenerationContext_1__String_1_, tableFunctionParamProcessor = processTableFunctionParamPlaceHolder_RelationalOperationElement_1__SqlGenerationContext_1__String_1_, - tabularFunctionProcessor = meta::relational::functions::sqlQueryToString::snowflake::tabularFunctionProcessor_String_1__String_1__String_1_, lateralJoinProcessor = processJoinTreeNodeWithLateralJoinForSnowflake_JoinTreeNode_1__DbConfig_1__Format_1__Extension_MANY__String_1_, joinProcessor = meta::relational::functions::sqlQueryToString::snowflake::processJoinForSnowflake_JoinTreeNode_1__DbConfig_1__Format_1__Extension_MANY__String_1_, joinStringsProcessor = processJoinStringsOperationForSnowflake_JoinStrings_1__SqlGenerationContext_1__String_1_, @@ -99,11 +98,6 @@ function <> meta::relational::functions::sqlQueryToString::snowf ); } -function meta::relational::functions::sqlQueryToString::snowflake::tabularFunctionProcessor(schema:String[1], functionName: String[1]):String[1] -{ - 'table('+ if($schema=='', | $functionName,| $schema+'.'+$functionName) + '())'; -} - function meta::relational::functions::sqlQueryToString::snowflake::schemaIdentifierToString(identifier:String[1], dbConfig: DbConfig[1]):String[1] { $identifier->split('.')->map(s|$s->processIdentifierWithQuoteChar('"', $dbConfig))->joinStrings('.'); diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-pure/src/main/resources/core_relational_snowflake/relational/tests/tabularFunctionModel.txt b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-pure/src/main/resources/core_relational_snowflake/relational/tests/tabularFunctionModel.txt deleted file mode 100644 index 7a1a07515b8..00000000000 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-pure/src/main/resources/core_relational_snowflake/relational/tests/tabularFunctionModel.txt +++ /dev/null @@ -1,318 +0,0 @@ -// Copyright 2024 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. - -###Relational -Database demo::udtf::DemoDb -( - Schema Org - ( - Table Firm - ( - firmId INTEGER, - legalname VARCHAR(200) - ) - TabularFunction Person - ( - firstname VARCHAR(200), - lastname VARCHAR(200), - age INTEGER, - associatedFirmId INTEGER - ) - TabularFunction Person2 - ( - firstname VARCHAR(200), - lastname VARCHAR(200), - age INTEGER, - associatedFirmId INTEGER - ) - TabularFunction ParentAndChildren - ( - firstname VARCHAR(200), - lastname VARCHAR(200), - id INTEGER, - age INTEGER, - parentId INTEGER - ) - ) - - Join firm_person(Org.Firm.firmId = Org.Person.associatedFirmId) - Join firm_person2(Org.Firm.firmId = Org.Person2.associatedFirmId) - Join relationship(Org.ParentAndChildren.parentId = {target}.id) - -) - - -###Pure -Class demo::udtf::Org::Firm -{ - firmId: Integer[1]; - legalname: String[1]; -} - -Class demo::udtf::Org::Person -{ - firstname: String[1]; - lastname: String[1]; - age: Integer[1]; - associatedFirmId: Integer[1]; - id: Integer[1]; -} - -Association demo::udtf::Person_person -{ - parent: demo::udtf::Org::Person[1]; - children: demo::udtf::Org::Person[1..*]; -} - -Association demo::udtf::firm_person -{ - assoacitedFirm: demo::udtf::Org::Firm[1]; - associatedPerson: demo::udtf::Org::Person[1..*]; -} - -function demo::udtf::Org::FirmToPerson(): meta::pure::tds::TabularDataSet[1] -{ - demo::udtf::Org::Firm.all() - ->project( - [ - x|$x.firmId, - x|$x.associatedPerson.age - ], - [ - 'Firm Id', - 'Associated Person/Age' - ] - )->from( - demo::udtf::DemoMapping, - demo::runtimes::DemoRuntime - ) -} - -function demo::udtf::Org::FirmToPersonWithFilterOnPerson(): meta::pure::tds::TabularDataSet[1] -{ - demo::udtf::Org::Firm.all()->filter( - x|$x.associatedPerson->exists( - x_1|$x_1.firstname == 'David' - ) - )->project( - [ - x|$x.firmId, - x|$x.associatedPerson.age - ], - [ - 'Firm Id', - 'Associated Person/Age' - ] - )->from( - demo::udtf::DemoMapping, - demo::runtimes::DemoRuntime - ) -} - -function demo::udtf::Org::FirmToPersonWithFilterOnPersonUsingUnion(): meta::pure::tds::TabularDataSet[1] -{ - demo::udtf::Org::Firm.all()->filter( - x|$x.associatedPerson->exists( - x_1|$x_1.firstname == 'David' - ) - )->project( - [ - x|$x.firmId, - x|$x.associatedPerson.age - ], - [ - 'Firm Id', - 'Associated Person/Age' - ] - )->from( - demo::udtf::DemoMappingUnion, - demo::runtimes::DemoRuntime - ) -} - - -function demo::udtf::Org::FetchChildrenViaSelfJoin(): meta::pure::tds::TabularDataSet[1] -{ - demo::udtf::Org::Person.all()->project( - [ - x|$x.firstname, - x|$x.id, - x|$x.children.age, - x|$x.children.id, - x|$x.children.firstname - ], - [ - 'Firstname', - 'Id', - 'Children/Age', - 'Children/Id', - 'Children/Firstname' - ] - )->from( - demo::udtf::DemoMappingSelfJoin, - demo::runtimes::DemoRuntime - ) -} - - -###Mapping -Mapping demo::udtf::DemoMapping -( - *demo::udtf::Org::Firm[f]: Relational - { - ~primaryKey - ( - [demo::udtf::DemoDb]Org.Firm.firmId, - [demo::udtf::DemoDb]Org.Firm.legalname - ) - ~mainTable [demo::udtf::DemoDb]Org.Firm - firmId: [demo::udtf::DemoDb]Org.Firm.firmId, - legalname: [demo::udtf::DemoDb]Org.Firm.legalname - } - *demo::udtf::Org::Person[p]: Relational - { - - ~mainTable [demo::udtf::DemoDb]Org.Person - firstname: [demo::udtf::DemoDb]Org.Person.firstname, - lastname: [demo::udtf::DemoDb]Org.Person.lastname, - age: [demo::udtf::DemoDb]Org.Person.age - } - - demo::udtf::firm_person: Relational - { - AssociationMapping - ( - assoacitedFirm[p,f]: [demo::udtf::DemoDb]@firm_person, - associatedPerson[f,p]: [demo::udtf::DemoDb]@firm_person - ) - } -) - -###Mapping -Mapping demo::udtf::DemoMappingUnion -( - *demo::udtf::Org::Person: Operation - { - meta::pure::router::operations::union_OperationSetImplementation_1__SetImplementation_MANY_(p1,p2) - } - *demo::udtf::Org::Firm[f]: Relational - { - ~primaryKey - ( - [demo::udtf::DemoDb]Org.Firm.firmId, - [demo::udtf::DemoDb]Org.Firm.legalname - ) - ~mainTable [demo::udtf::DemoDb]Org.Firm - firmId: [demo::udtf::DemoDb]Org.Firm.firmId, - legalname: [demo::udtf::DemoDb]Org.Firm.legalname - } - demo::udtf::Org::Person[p1]: Relational - { - ~mainTable [demo::udtf::DemoDb]Org.Person - firstname: [demo::udtf::DemoDb]Org.Person.firstname, - lastname: [demo::udtf::DemoDb]Org.Person.lastname, - age: [demo::udtf::DemoDb]Org.Person.age - } - demo::udtf::Org::Person[p2]: Relational - { - ~mainTable [demo::udtf::DemoDb]Org.Person2 - firstname: [demo::udtf::DemoDb]Org.Person2.firstname, - lastname: [demo::udtf::DemoDb]Org.Person2.lastname, - age: [demo::udtf::DemoDb]Org.Person2.age - } - - demo::udtf::firm_person: Relational - { - AssociationMapping - ( - assoacitedFirm[p1,f]: [demo::udtf::DemoDb]@firm_person, - assoacitedFirm[p2,f]: [demo::udtf::DemoDb]@firm_person2, - associatedPerson[f,p1]: [demo::udtf::DemoDb]@firm_person, - associatedPerson[f,p2]: [demo::udtf::DemoDb]@firm_person2 - ) - } -) - -###Mapping -Mapping demo::udtf::DemoMappingSelfJoin -( - *demo::udtf::Org::Person[p1]: Relational - { - ~primaryKey - ( - [demo::udtf::DemoDb]Org.ParentAndChildren.firstname - ) - ~mainTable [demo::udtf::DemoDb]Org.ParentAndChildren - firstname: [demo::udtf::DemoDb]Org.ParentAndChildren.firstname, - lastname: [demo::udtf::DemoDb]Org.ParentAndChildren.lastname, - id: [demo::udtf::DemoDb]Org.ParentAndChildren.id, - age: [demo::udtf::DemoDb]Org.ParentAndChildren.age - } - - demo::udtf::Person_person: Relational - { - AssociationMapping - ( - children[p1,p1]: [demo::udtf::DemoDb]@relationship, - parent[p1,p1]: [demo::udtf::DemoDb]@relationship - ) - } -) - -###Connection -RelationalDatabaseConnection demo::udtf::DemoSnowflakeConnection -{ - store: demo::udtf::DemoDb; - type: Snowflake; - specification: Snowflake - { - name: 'SUMMIT_MDM_DATA'; - account: 'sfcedeawseast1d01'; - warehouse: 'DEMO_WH'; - region: 'us-east-1'; - }; - auth: SnowflakePublic - { - publicUserName: 'isThis'; - privateKeyVaultReference: 'Hi'; - passPhraseVaultReference: 'What'; - }; -} - - -###Runtime -Runtime demo::runtimes::DemoRuntime -{ - mappings: - [ - demo::udtf::DemoMapping - ]; - connections: - [ - demo::udtf::DemoDb: - [ - connection_2: demo::udtf::DemoSnowflakeConnection - ] - ]; -} - -###Snowflake -SnowflakeApp demo::udtf::snowflakeApp::App1 -{ - applicationName : 'App1_revised'; - function : demo::udtf::Org::FirmToPersonWithFilterOnPersonUsingUnion():TabularDataSet[1]; - ownership : Deployment { identifier: '441143'}; - description : 'test App'; - activationConfiguration : demo::udtf::DemoSnowflakeConnection; -} \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-pure/src/main/resources/core_relational_snowflake/relational/tests/testTabularFunctionQuery.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-pure/src/main/resources/core_relational_snowflake/relational/tests/testTabularFunctionQuery.pure deleted file mode 100644 index d144dd4e2eb..00000000000 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-pure/src/main/resources/core_relational_snowflake/relational/tests/testTabularFunctionQuery.pure +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2024 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. - -import meta::pure::executionPlan::toString::*; -import meta::pure::profiles::*; - -function <> meta::relational::tests::query::snowflake::testSimpleSelect():Any[*] -{ - let result = meta::legend::compileLegendGrammar(readFile('/core_relational_snowflake/relational/tests/tabularFunctionModel.txt')->toOne()); - let func = $result->filter(f|$f->instanceOf(ConcreteFunctionDefinition)) - ->cast(@ConcreteFunctionDefinition)->filter(c| $c.name=='FirmToPerson__TabularDataSet_1_')->toOne(); - let query = 'select "root".firmId as "Firm Id", "person_0".age as "Associated Person/Age" from Org.Firm as "root" left outer join table(Org.Person()) as "person_0" on ("root".firmId = "person_0".associatedFirmId)'; - assert(meta::pure::executionPlan::executionPlan($func, meta::relational::extension::relationalExtensions())->planToString(meta::relational::extension::relationalExtensions())->contains($query)); -} - -function <> meta::relational::tests::query::snowflake::testExists():Any[*] -{ - let result = meta::legend::compileLegendGrammar(readFile('/core_relational_snowflake/relational/tests/tabularFunctionModel.txt')->toOne()); - let func = $result->filter(f|$f->instanceOf(ConcreteFunctionDefinition)) - ->cast(@ConcreteFunctionDefinition)->filter(c| $c.name=='FirmToPersonWithFilterOnPerson__TabularDataSet_1_')->toOne(); - let query = 'select "root".firmId as "Firm Id", "person_2".age as "Associated Person/Age" from Org.Firm as "root" left outer join (select distinct "person_1".associatedFirmId from table(Org.Person()) as "person_1" where "person_1".firstname = \'David\') as "person_0" on ("root".firmId = "person_0".associatedFirmId) left outer join table(Org.Person()) as "person_2" on ("root".firmId = "person_2".associatedFirmId) where "person_0".associatedFirmId is not null'; - assert(meta::pure::executionPlan::executionPlan($func, meta::relational::extension::relationalExtensions())->planToString(meta::relational::extension::relationalExtensions())->contains($query)); -} - -function <> meta::relational::tests::query::snowflake::testExistsAndUnion():Any[*] -{ - let result = meta::legend::compileLegendGrammar(readFile('/core_relational_snowflake/relational/tests/tabularFunctionModel.txt')->toOne()); - let func = $result->filter(f|$f->instanceOf(ConcreteFunctionDefinition)) - ->cast(@ConcreteFunctionDefinition)->filter(c| $c.name=='FirmToPersonWithFilterOnPersonUsingUnion__TabularDataSet_1_')->toOne(); - let query = 'select "root".firmId as "Firm Id", "unionalias_0"."Personage_Person2age" as "Associated Person/Age" from Org.Firm as "root" left outer join (select "root".associatedFirmId as associatedFirmId_0, null as associatedFirmId_1, "root".age as "Personage_Person2age" from table(Org.Person()) as "root" UNION ALL select null as associatedFirmId_0, "root".associatedFirmId as associatedFirmId_1, "root".age as "Personage_Person2age" from table(Org.Person2()) as "root") as "unionalias_0" on ("root".firmId = "unionalias_0".associatedFirmId_0 or "root".firmId = "unionalias_0".associatedFirmId_1) where exists(select 1 from (select "root".associatedFirmId as associatedFirmId_0, null as associatedFirmId_1, "root".firstname as "Personfirstname_Person2firstname" from table(Org.Person()) as "root" UNION ALL select null as associatedFirmId_0, "root".associatedFirmId as associatedFirmId_1, "root".firstname as "Personfirstname_Person2firstname" from table(Org.Person2()) as "root") as "unionalias_1" where ("root".firmId = "unionalias_1".associatedFirmId_0 or "root".firmId = "unionalias_1".associatedFirmId_1) and "unionalias_1"."Personfirstname_Person2firstname" = \'David\')'; - assert(meta::pure::executionPlan::executionPlan($func, meta::relational::extension::relationalExtensions())->planToString(meta::relational::extension::relationalExtensions())->contains($query)); -} - -function <> meta::relational::tests::query::snowflake::testSelfJoin():Any[*] -{ - let result = meta::legend::compileLegendGrammar(readFile('/core_relational_snowflake/relational/tests/tabularFunctionModel.txt')->toOne()); - let func = $result->filter(f|$f->instanceOf(ConcreteFunctionDefinition)) - ->cast(@ConcreteFunctionDefinition)->filter(c| $c.name=='FetchChildrenViaSelfJoin__TabularDataSet_1_')->toOne(); - let query = 'select "root".firstname as "Firstname", "root".id as "Id", "parentandchildren_1".age as "Children/Age", "parentandchildren_1".id as "Children/Id", "parentandchildren_1".firstname as "Children/Firstname" from table(Org.ParentAndChildren()) as "root" left outer join table(Org.ParentAndChildren()) as "parentandchildren_1" on ("root".parentId = "parentandchildren_1".id)'; - assert(meta::pure::executionPlan::executionPlan($func, meta::relational::extension::relationalExtensions())->planToString(meta::relational::extension::relationalExtensions())->contains($query)); -} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/RelationalLexerGrammar.g4 b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/RelationalLexerGrammar.g4 index 899ce2b3b26..79408581b13 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/RelationalLexerGrammar.g4 +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/RelationalLexerGrammar.g4 @@ -12,7 +12,6 @@ INCLUDE: 'include'; TABLE: 'Table'; SCHEMA: 'Schema'; VIEW: 'View'; -TABULAR_FUNC: 'TabularFunction'; FILTER: 'Filter'; MULTIGRAIN_FILTER: 'MultiGrainFilter'; JOIN: 'Join'; diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/RelationalParserGrammar.g4 b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/RelationalParserGrammar.g4 index de4b8eff0dc..fdd7d35f302 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/RelationalParserGrammar.g4 +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/RelationalParserGrammar.g4 @@ -17,7 +17,7 @@ unquotedIdentifier: VALID_STRING | MILESTONING | BUSINESS_MILESTONING | BUSINESS_MILESTONING_FROM | BUSINESS_MILESTONING_THRU | OUT_IS_INCLUSIVE | THRU_IS_INCLUSIVE | INFINITY_DATE | BUS_SNAPSHOT_DATE | PROCESSING_MILESTONING | PROCESSING_MILESTONING_IN | PROCESSING_MILESTONING_OUT - | SCOPE | ENUMERATION_MAPPING | ASSOCIATION_MAPPING | OTHERWISE | INLINE | BINDING | TABULAR_FUNC + | SCOPE | ENUMERATION_MAPPING | ASSOCIATION_MAPPING | OTHERWISE | INLINE | BINDING ; identifier: unquotedIdentifier | STRING @@ -36,7 +36,6 @@ database: DATABASE stereotypes? qualifiedName | table | view | join - | tabularFunction | filter | multiGrainFilter )* @@ -58,7 +57,6 @@ schema: SCHEMA identifier ( table | view - | tabularFunction )* PAREN_CLOSE ; @@ -134,13 +132,6 @@ viewGroupBy: GROUP_BY_CMD viewColumnMapping: identifier (BRACKET_OPEN identifier BRACKET_CLOSE)? COLON operation PRIMARY_KEY? ; -// -------------------------------------- TABULAR FUNCTION -------------------------------------- -tabularFunction: TABULAR_FUNC relationalIdentifier - PAREN_OPEN - (columnDefinition (COMMA columnDefinition)*)? - PAREN_CLOSE -; - // -------------------------------------- FILTER & JOIN -------------------------------------- diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperRelationalBuilder.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperRelationalBuilder.java index 3dada25720a..5eb03a9646e 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperRelationalBuilder.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperRelationalBuilder.java @@ -107,7 +107,6 @@ import org.finos.legend.pure.generated.Root_meta_relational_metamodel_relation_BusinessSnapshotMilestoning_Impl; import org.finos.legend.pure.generated.Root_meta_relational_metamodel_relation_ProcessingMilestoning_Impl; import org.finos.legend.pure.generated.Root_meta_relational_metamodel_relation_Table_Impl; -import org.finos.legend.pure.generated.Root_meta_relational_metamodel_relation_TabularFunction_Impl; import org.finos.legend.pure.generated.Root_meta_relational_metamodel_relation_View_Impl; import org.finos.legend.pure.generated.core_pure_model_modelUnit; import org.finos.legend.pure.m2.relational.M2RelationalPaths; @@ -158,7 +157,6 @@ import org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.ProcessingMilestoning; import org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.Relation; import org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.Table; -import org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.TabularFunction; import org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.View; import org.finos.legend.pure.m3.navigation.M3Paths; import org.finos.legend.pure.m3.navigation.PackageableElement.PackageableElement; @@ -328,10 +326,6 @@ private static Relation findRelation(Database database, final String schemaName, { table = schema._views().detect(v -> tableName.equals(v._name())); } - if (table == null) - { - table = schema._tabularFunctions().detect(tf -> tableName.equals(tf._name())); - } if (table != null) { tables.add(table); @@ -420,8 +414,7 @@ public static Schema processDatabaseSchema(org.finos.legend.engine.protocol.pure { Schema schema = new Root_meta_relational_metamodel_Schema_Impl(srcSchema.name, SourceInformationHelper.toM3SourceInformation(srcSchema.sourceInformation), context.pureModel.getClass("meta::relational::metamodel::Schema"))._name(srcSchema.name); RichIterable tables = ListIterate.collect(srcSchema.tables, _table -> processDatabaseTable(_table, context, schema)); - RichIterable functions = ListIterate.collect(srcSchema.tabularFunctions, _function -> processDatabaseFunction(_function, context, schema)); - return schema._tables(tables)._tabularFunctions(functions)._database(database); + return schema._tables(tables)._database(database); } public static Schema processDatabaseSchemaViewsFirstPass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Schema srcSchema, CompileContext context, Database database) @@ -466,13 +459,6 @@ public static Table processDatabaseTable(org.finos.legend.engine.protocol.pure.v return table._columns(columns)._primaryKey(pk)._schema(schema)._milestoning(milestoning); } - public static TabularFunction processDatabaseFunction(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.TabularFunction srcFunction, CompileContext context, Schema schema) - { - TabularFunction tabularFunction = new Root_meta_relational_metamodel_relation_TabularFunction_Impl(srcFunction.name, SourceInformationHelper.toM3SourceInformation(srcFunction.sourceInformation), context.pureModel.getClass("meta::relational::metamodel::relation::TabularFunction"))._name(srcFunction.name); - MutableList columns = ListIterate.collect(srcFunction.columns, column -> new Root_meta_relational_metamodel_Column_Impl(column.name, SourceInformationHelper.toM3SourceInformation(column.sourceInformation), context.pureModel.getClass("meta::relational::metamodel::Column"))._name(column.name)._name(column.name)._nullable(column.nullable)._type(transformDatabaseDataType(column.type, context))._owner(tabularFunction)); - return tabularFunction._columns(columns)._schema(schema); - } - public static View processDatabaseViewFirstPass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.View srcView, CompileContext context, Schema schema) { View view = new Root_meta_relational_metamodel_relation_View_Impl(srcView.name, SourceInformationHelper.toM3SourceInformation(srcView.sourceInformation), context.pureModel.getClass("meta::relational::metamodel::relation::View"))._name(srcView.name); diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/from/RelationalParseTreeWalker.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/from/RelationalParseTreeWalker.java index 0dc27eef52c..d5d05a90d36 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/from/RelationalParseTreeWalker.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/from/RelationalParseTreeWalker.java @@ -55,7 +55,6 @@ import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.MultiGrainFilter; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Schema; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Table; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.TabularFunction; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.View; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.BigInt; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Binary; @@ -131,15 +130,13 @@ private Database visitDatabase(RelationalParserGrammar.DatabaseContext ctx) // NOTE: if tables and views are defined without a schema, create a default schema to hold these List
tables = ListIterate.collect(ctx.table(), this::visitTable); List views = ListIterate.collect(ctx.view(), viewCtx -> this.visitView(viewCtx, scopeInfo)); - List tabularFunctions = ListIterate.collect(ctx.tabularFunction(), funcCtx -> this.visitTabularFunc(funcCtx)); - if (!tables.isEmpty() || !views.isEmpty() || !tabularFunctions.isEmpty()) + if (!tables.isEmpty() || !views.isEmpty()) { Schema schema = new Schema(); schema.sourceInformation = database.sourceInformation; schema.name = "default"; schema.tables = tables; schema.views = views; - schema.tabularFunctions = tabularFunctions; database.schemas.add(schema); } database.joins = ListIterate.collect(ctx.join(), joinCtx -> this.visitJoin(joinCtx, scopeInfo)); @@ -177,7 +174,6 @@ public Schema visitSchema(RelationalParserGrammar.SchemaContext ctx, ScopeInfo s 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())); - schema.tabularFunctions = ListIterate.collect(ctx.tabularFunction(), funcCtx -> this.visitTabularFunc(funcCtx)); return schema; } @@ -543,20 +539,6 @@ public ColumnMapping visitViewColumnMapping(RelationalParserGrammar.ViewColumnMa return columnMapping; } - // ----------------------------------------------- TABULAR FUNCTION ----------------------------------------------- - - private TabularFunction visitTabularFunc(RelationalParserGrammar.TabularFunctionContext ctx) - { - TabularFunction tabularFunction = new TabularFunction(); - tabularFunction.sourceInformation = this.walkerSourceInformation.getSourceInformation(ctx); - tabularFunction.name = ctx.relationalIdentifier().getText(); - List primaryKeys = FastList.newList(); - tabularFunction.columns = ListIterate.collect(ctx.columnDefinition(), columnDefinitionContext -> this.visitColumnDefinition(columnDefinitionContext, primaryKeys)); - return tabularFunction; - } - - - // ----------------------------------------------- JOIN ----------------------------------------------- diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/to/HelperRelationalGrammarComposer.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/to/HelperRelationalGrammarComposer.java index a5c0f6a5282..b8a9745a3c7 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/to/HelperRelationalGrammarComposer.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/to/HelperRelationalGrammarComposer.java @@ -14,7 +14,6 @@ package org.finos.legend.engine.language.pure.grammar.to; -import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.impl.utility.LazyIterate; import org.eclipse.collections.impl.utility.ListIterate; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.PropertyMapping; @@ -44,7 +43,6 @@ import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.ColumnMapping; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Schema; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Table; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.TabularFunction; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.View; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.BigInt; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.datatype.Binary; @@ -316,12 +314,6 @@ public static String renderDatabaseSchema(Schema schema, RelationalGrammarCompos builder.append(LazyIterate.collect(schema.views, view -> renderDatabaseView(view, baseIndentation + 1, context)).makeString("\n")); builder.append("\n"); } - if (!schema.tabularFunctions.isEmpty()) - { - builder.append(nonEmpty ? "\n" : ""); - builder.append(LazyIterate.collect(schema.tabularFunctions, tFunc -> renderDatabaseTabularFunction(tFunc, baseIndentation + 1, context)).makeString("\n")); - builder.append("\n"); - } builder.append(getTabString(baseIndentation)).append(")"); return builder.toString(); } @@ -352,23 +344,6 @@ public static String renderDatabaseTable(Table table, int baseIndentation, Relat return builder.toString(); } - public static String renderDatabaseTabularFunction(TabularFunction tabularFunction, int baseIndentation, RelationalGrammarComposerContext context) - { - StringBuilder builder = new StringBuilder(); - builder.append(getTabString(baseIndentation)).append("TabularFunction ").append(tabularFunction.name).append("\n"); - builder.append(getTabString(baseIndentation)).append("(\n"); - boolean nonEmpty = false; - - if (!tabularFunction.columns.isEmpty()) - { - builder.append(nonEmpty ? "\n" : ""); - builder.append(LazyIterate.collect(tabularFunction.columns, column -> renderDatabaseTableColumn(column, Lists.mutable.empty(), baseIndentation + 1)).makeString(",\n")); - builder.append("\n"); - } - builder.append(getTabString(baseIndentation)).append(")"); - return builder.toString(); - } - private static String renderDatabaseTableColumn(Column column, List primaryKeys, int baseIndentation) { StringBuilder builder = new StringBuilder(); diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/to/RelationalGrammarComposerExtension.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/to/RelationalGrammarComposerExtension.java index cfeac3124ab..408044f0f24 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/to/RelationalGrammarComposerExtension.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/to/RelationalGrammarComposerExtension.java @@ -284,13 +284,6 @@ private static String renderDatabase(Database database, PureGrammarComposerConte builder.append("\n"); nonEmpty = true; } - if (defaultSchema != null && !defaultSchema.tabularFunctions.isEmpty()) - { - builder.append(nonEmpty ? "\n" : ""); - builder.append(LazyIterate.collect(defaultSchema.tabularFunctions, tabularFunction -> HelperRelationalGrammarComposer.renderDatabaseTabularFunction(tabularFunction, 1, context)).makeString("\n")); - builder.append("\n"); - nonEmpty = true; - } if (defaultSchema != null && !defaultSchema.views.isEmpty()) { builder.append(nonEmpty ? "\n" : ""); diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/test/java/org/finos/legend/engine/language/pure/compiler/test/TestRelationalCompilationFromGrammar.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/test/java/org/finos/legend/engine/language/pure/compiler/test/TestRelationalCompilationFromGrammar.java index 288d5abf457..e5c9a80a8a6 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/test/java/org/finos/legend/engine/language/pure/compiler/test/TestRelationalCompilationFromGrammar.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/test/java/org/finos/legend/engine/language/pure/compiler/test/TestRelationalCompilationFromGrammar.java @@ -1151,106 +1151,6 @@ public void testRelationalMapping() } - @Test - public void testRelationalMappingToTabularFunc() - { - Pair res = test("Class simple::Person\n" + - "{\n" + - " firstName: String[1];\n" + - " lastName: String[1];\n" + - " age: Integer[1];\n" + - "}\n" + - "\n" + - "Class simple::Firm\n" + - "{\n" + - " employees: simple::Person[*];\n" + - " legalName: String[1];\n" + - "}\n" + - "\n" + - "Enum simple::GeographicEntityType\n" + - "{\n" + - " CITY,\n" + - " COUNTRY,\n" + - " REGION\n" + - "}\n" + - "\n" + - "\n" + - "###Relational\n" + - "Database simple::dbInc\n" + - "(\n" + - " TabularFunction personFunction\n" + - " (\n" + - " ID INTEGER PRIMARY KEY,\n" + - " FIRSTNAME VARCHAR(200),\n" + - " LASTNAME VARCHAR(200),\n" + - " AGE INTEGER,\n" + - " ADDRESSID INTEGER,\n" + - " FIRMID INTEGER,\n" + - " MANAGERID INTEGER\n" + - " )\n" + - " Table firmTable\n" + - " (\n" + - " ID INTEGER PRIMARY KEY,\n" + - " LEGALNAME VARCHAR(200),\n" + - " ADDRESSID INTEGER,\n" + - " CEOID INTEGER\n" + - " )\n" + - - " View FirmView\n" + - " (\n" + - " id: firmTable.ID PRIMARY KEY, \n" + - " legal: firmTable.LEGALNAME\n" + - "\n" + - " )\n" + - " Join Firm_FirmView(firmTable.ID = FirmView.id)\n" + - " Join Firm_Person(firmTable.ID = personFunction.FIRMID)\n" + - ")\n" + - "\n" + - "\n" + - "###Mapping\n" + - "Mapping simple::simpleRelationalMappingInc\n" + - "(\n" + - " simple::Person[simple_Person]: Relational\n" + - " {\n" + - " firstName: [simple::dbInc]personFunction.FIRSTNAME,\n" + - " lastName: [simple::dbInc]personFunction.LASTNAME,\n" + - " age: [simple::dbInc]personFunction.AGE\n" + - " }\n" + - " simple::Firm[simple_Firm]: Relational\n" + - " {\n" + - " ~mainTable [simple::dbInc]firmTable\n" + - " legalName: [simple::dbInc]firmTable.LEGALNAME,\n" + - " employees: [simple::dbInc]@Firm_Person\n" + - " }\n" + - "\n" + - " simple::GeographicEntityType: EnumerationMapping GE\n" + - " {\n" + - " CITY: [1]\n" + - " }\n" + - ")"); - - // user has not defined mainTable - test("Class model::Person {\n" + - " name:String[1];\n" + - "}\n" + - "###Relational\n" + - "Database model::store::db\n" + - "(\n" + - " Table myTable(name VARCHAR(200))\n" + - ")\n" + - "###Mapping\n" + - "Mapping \n" + - "model::mapping::myMap\n" + - "(\n" + - " model::Person: Relational\n" + - " {\n" + - " name : [model::store::db]myTable.name\n" + - " }\n" + - ")" - ); - - - } @Test public void testMappingWithSourceTargetID() diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/TestRelationalGrammarRoundtrip.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/TestRelationalGrammarRoundtrip.java index 1d4a6d2681c..c474bc1ac53 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/TestRelationalGrammarRoundtrip.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/TestRelationalGrammarRoundtrip.java @@ -89,17 +89,6 @@ public void testRelationalSimpleFull() " NAME VARCHAR(200)\n" + " )\n" + "\n" + - " TabularFunction personFunction\n" + - " (\n" + - " ID INTEGER,\n" + - " FIRSTNAME VARCHAR(200),\n" + - " LASTNAME VARCHAR(200),\n" + - " AGE INTEGER,\n" + - " ADDRESSID INTEGER,\n" + - " FIRMID INTEGER,\n" + - " MANAGERID INTEGER\n" + - " )\n" + - "\n" + " Join Address_Firm(addressTable.ID = firmTable.ADDRESSID)\n" + " Join Address_Person(addressTable.ID = personTable.ADDRESSID = personTable.ADDRESSID)\n" + " Join Address_Firm(addressTable.ID = firmTable.ADDRESSID and (addressTable.ID = firmTable.ADDRESSID and addressTable.ID = firmTable.ADDRESSID) and (addressTable.ID = firmTable.ADDRESSID or addressTable.ID = firmTable.ADDRESSID or addressTable.ID = firmTable.ADDRESSID or addressTable.ID = firmTable.ADDRESSID) and (addressTable.ID = firmTable.YEEEEEE or addressTable.ID = firmTable.ADDRESSID) and addressTable.ID = firmTable.niketh)\n" + diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-http-api/src/test/java/org.finos.legend.engine.language.pure.grammar.api.relationalOperationElement.test/TestRelationalOperationElementApi.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-http-api/src/test/java/org.finos.legend.engine.language.pure.grammar.api.relationalOperationElement.test/TestRelationalOperationElementApi.java index 21f96123764..1c82eb4e140 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-http-api/src/test/java/org.finos.legend.engine.language.pure.grammar.api.relationalOperationElement.test/TestRelationalOperationElementApi.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-http-api/src/test/java/org.finos.legend.engine.language.pure.grammar.api.relationalOperationElement.test/TestRelationalOperationElementApi.java @@ -42,7 +42,7 @@ public void testSimple() @Test public void testSimpleError() { - testError("add(1,", "Unexpected token ''. Valid alternatives: ['Database', 'include', 'Table', 'Schema', 'View', 'TabularFunction', 'Filter', 'MultiGrainFilter', 'Join', '{target}', 'and', 'or', 'milestoning', 'business', 'BUS_FROM', 'BUS_THRU', 'THRU_IS_INCLUSIVE', 'BUS_SNAPSHOT_DATE', 'processing', 'PROCESSING_IN', 'PROCESSING_OUT', 'OUT_IS_INCLUSIVE', 'INFINITY_DATE', 'AssociationMapping', 'EnumerationMapping', 'Otherwise', 'Inline', 'Binding', 'scope', '[', '(', '@']", new SourceInformation("", 1, 7, 1, 11)); + testError("add(1,", "Unexpected token ''. Valid alternatives: ['Database', 'include', 'Table', 'Schema', 'View', 'Filter', 'MultiGrainFilter', 'Join', '{target}', 'and', 'or', 'milestoning', 'business', 'BUS_FROM', 'BUS_THRU', 'THRU_IS_INCLUSIVE', 'BUS_SNAPSHOT_DATE', 'processing', 'PROCESSING_IN', 'PROCESSING_OUT', 'OUT_IS_INCLUSIVE', 'INFINITY_DATE', 'AssociationMapping', 'EnumerationMapping', 'Otherwise', 'Inline', 'Binding', 'scope', '[', '(', '@']", new SourceInformation("", 1, 7, 1, 11)); } @Test diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-protocol/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/packageableElement/store/relational/model/Schema.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-protocol/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/packageableElement/store/relational/model/Schema.java index e5f8074d07f..d798891e1e0 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-protocol/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/packageableElement/store/relational/model/Schema.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-protocol/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/packageableElement/store/relational/model/Schema.java @@ -24,6 +24,5 @@ public class Schema public String name; public List
tables = Collections.emptyList(); public List views = Collections.emptyList(); - public List tabularFunctions = Collections.emptyList(); public SourceInformation sourceInformation; } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-protocol/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/packageableElement/store/relational/model/TabularFunction.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-protocol/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/packageableElement/store/relational/model/TabularFunction.java deleted file mode 100644 index 64272dbd3fb..00000000000 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-protocol/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/packageableElement/store/relational/model/TabularFunction.java +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2024 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.protocol.pure.v1.model.packageableElement.store.relational.model; - -import org.finos.legend.engine.protocol.pure.v1.model.SourceInformation; - -import java.util.Collections; -import java.util.List; - -public class TabularFunction -{ - //TODO params ? - public String name; - public List columns = Collections.emptyList(); - public SourceInformation sourceInformation; -} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/postprocessor/defaultPostProcessor/reAliasQuery.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/postprocessor/defaultPostProcessor/reAliasQuery.pure index a9767154f8f..444754ece97 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/postprocessor/defaultPostProcessor/reAliasQuery.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/postprocessor/defaultPostProcessor/reAliasQuery.pure @@ -49,7 +49,6 @@ function <> meta::relational::postProcessor::reAlias::traverse(q u:Union[1] | pair('unionAlias', $alias.name)->concatenate($u->traverse());, v:ViewSelectSQLQuery[1] | pair($relElement->cast(@Table).name, $alias.name)->concatenate($v.selectSQLQuery->traverse());, t:Table[1] | pair($relElement->cast(@Table).name, $alias.name);, - tf:TabularFunction[1] | pair($relElement->cast(@TabularFunction).name, $alias.name);, c:CommonTableExpressionReference[1] | pair($relElement->cast(@CommonTableExpressionReference).name, $alias.name);, s:SelectSQLQuery[1] | let childPairs = $s->traverse(); if($childPairs->isNotEmpty(), @@ -78,7 +77,6 @@ function <> meta::relational::postProcessor::reAlias::traverse(q let relElement = $ta.relationalElement; $relElement->match([ t:Table[1] | pair($t.name,$name);, - tf:TabularFunction[1] | pair($tf.name,$name);, c:CommonTableExpressionReference[1] | pair($c.name,$name);, u:Union[1] | pair('unionAlias', $name)->concatenate($u->traverse());, s:SelectSQLQuery[1] | let children = $s->traverse(); @@ -177,7 +175,6 @@ function <> meta::relational::postProcessor::reAlias::transformA ^$ta(name = $new->toOne(),relationalElement = $transformedRelElement);, t:Table[1] | $t, - tf:TabularFunction[1] | $tf, t:CommonTableExpressionReference[1] | $t, diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/postprocessor/defaultPostProcessor/trimColumnNamePostProcessor.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/postprocessor/defaultPostProcessor/trimColumnNamePostProcessor.pure index 809f38ddb30..4ac105b64f8 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/postprocessor/defaultPostProcessor/trimColumnNamePostProcessor.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/postprocessor/defaultPostProcessor/trimColumnNamePostProcessor.pure @@ -78,7 +78,6 @@ function meta::relational::postProcessor::reAliasColumnName::search(q:Relationa ->concatenate($s.filteringOperation->search($runtime));, ta:TableAlias[1]| let name = $ta.name; let relElement = $ta.relationalElement; $relElement->match([t:Table[1]|[], - tf:TabularFunction[1]|[], u: Union[1]|$u->search($runtime), s: SelectSQLQuery[1]|$s->search($runtime);, s: SemiStructuredArrayFlatten[1]|$s.navigation->search($runtime) diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/pureToSQLQuery/pureToSQLQuery.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/pureToSQLQuery/pureToSQLQuery.pure index ce62e41a6c3..e9cb2539c3b 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/pureToSQLQuery/pureToSQLQuery.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/pureToSQLQuery/pureToSQLQuery.pure @@ -3865,7 +3865,6 @@ function meta::relational::functions::pureToSqlQuery::processRelation(r: Relatio $r->match([ s:SelectSQLQuery[1] | $s, t:Table[1] | $t, - f:TabularFunction[1] | $f, u:Union[1] | $u, v:View[1] | let selectWithCursor = processRelationalMappingSpecification($v, $c, $nodeId, $addPk, $pkOffset, true, $milestoningContext, ^$state(inFilter=false), $context, $extensions); let select = $selectWithCursor.select; @@ -7883,7 +7882,6 @@ function meta::relational::functions::pureToSqlQuery::findMainTable(relation : R function meta::relational::functions::pureToSqlQuery::findMainNamedRelation(relation : RelationalOperationElement[1]):NamedRelation[1] { $relation->match([v:View[1]|$v, - tf:TabularFunction[1]|$tf, s:SelectSQLQuery[1]|if($s.preIsolationCurrentTreeNode->isEmpty(), |$s.data->toOne()->findLastJoinTreeNode(), |$s.preIsolationCurrentTreeNode->toOne(); diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/sqlQueryToString/dbExtension.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/sqlQueryToString/dbExtension.pure index 856426766e9..bb237780901 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/sqlQueryToString/dbExtension.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/sqlQueryToString/dbExtension.pure @@ -70,12 +70,6 @@ Class meta::relational::functions::sqlQueryToString::DbConfig $this.dbExtension.windowColumnProcessor->toOne()->eval($w, $sgc); }: String[1]; - tabularFunctionProcessor(schema: String[1], functionName:String[1]) - { - assert($this.dbExtension.tabularFunctionProcessor->isNotEmpty(), '[unsupported-api] Tabular Functions not supported for Database Type: ' + $this.dbType->toString()); - $this.dbExtension.tabularFunctionProcessor->toOne()->eval($schema, $functionName); - }:String[1]; - semiStructuredElementProcessor(s:RelationalOperationElement[1], sgc:SqlGenerationContext[1]) { assert($this.dbExtension.semiStructuredElementProcessor->isNotEmpty(), '[unsupported-api] Semi structured array element processing not supported for Database Type: ' + $this.dbType->toString()); @@ -240,7 +234,6 @@ Class meta::relational::functions::sqlQueryToString::DbExtension isDbReservedIdentifier: meta::pure::metamodel::function::Function<{String[1] -> Boolean[1]}>[1]; literalProcessor: meta::pure::metamodel::function::Function<{Type[1] -> LiteralProcessor[1]}>[1]; windowColumnProcessor: meta::pure::metamodel::function::Function<{WindowColumn[1], SqlGenerationContext[1] -> String[1]}>[0..1]; - tabularFunctionProcessor: meta::pure::metamodel::function::Function<{String[1], String[1] -> String[1]}>[0..1]; semiStructuredElementProcessor: meta::pure::metamodel::function::Function<{RelationalOperationElement[1], SqlGenerationContext[1] -> String[1]}>[0..1]; tableFunctionParamProcessor: meta::pure::metamodel::function::Function<{RelationalOperationElement[1], SqlGenerationContext[1] -> String[1]}>[0..1]; lateralJoinProcessor : meta::pure::metamodel::function::Function<{JoinTreeNode[1], DbConfig[1], Format[1], Extension[*] -> String[1]}>[0..1]; @@ -408,7 +401,6 @@ function meta::relational::functions::sqlQueryToString::processOperation(relatio w:WindowColumn[1]|$dbConfig.windowColumnProcessor($w, $sgc), s:ViewSelectSQLQuery[1]|'('+$s.selectSQLQuery->processOperation($dbConfig, $format, $generationState, $config, $extensions)+')', t:Table[1]|$t->tableToString($dbConfig), - tf:TabularFunction[1]|$tf->tabularFunctionToString($dbConfig), js:JoinStrings[1] | $dbConfig.joinStringsProcessor($js, ^$sgc(config=^Config())), alias:Alias[1]| let innerTerm = $alias.relationalElement->match([ @@ -481,16 +473,6 @@ function meta::relational::functions::sqlQueryToString::tableToString(table:Tabl ) } -function meta::relational::functions::sqlQueryToString::tabularFunctionToString(tf:TabularFunction[1], dbConfig : DbConfig[1]):String[1] -{ - let schemaName = $dbConfig.tableNameToIdentifier($tf.schema.name); - let functionName = $dbConfig.tableNameToIdentifier($tf.name); - if($schemaName == 'default', - | $dbConfig.tabularFunctionProcessor('', $dbConfig.identifierProcessor($functionName)), - | $dbConfig.tabularFunctionProcessor($dbConfig.schemaIdentifierToString($schemaName) , $dbConfig.identifierProcessor($functionName))); - -} - function meta::relational::functions::sqlQueryToString::indent(d:Format[1]):Format[1] { ^$d(indentStack += $d.indent); diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/sqlQueryToString/dbSpecific/debugPrint/debugPrintExtension.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/sqlQueryToString/dbSpecific/debugPrint/debugPrintExtension.pure index 40bb9e9d420..671e0f85069 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/sqlQueryToString/dbSpecific/debugPrint/debugPrintExtension.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/sqlQueryToString/dbSpecific/debugPrint/debugPrintExtension.pure @@ -31,7 +31,6 @@ function meta::relational::functions::sqlQueryToString::debugPrint::createDbExte isDbReservedIdentifier = {str:String[1]| $str->toLower()->in($reservedWords)}, literalProcessor = $literalProcessor, windowColumnProcessor = processWindowColumn_WindowColumn_1__SqlGenerationContext_1__String_1_, - tabularFunctionProcessor = meta::relational::functions::sqlQueryToString::debugPrint::tabularFunctionProcessor_String_1__String_1__String_1_, lateralJoinProcessor = processJoinTreeNodeWithLateralJoinForH2_JoinTreeNode_1__DbConfig_1__Format_1__Extension_MANY__String_1_, semiStructuredElementProcessor = processSemiStructuredElementForH2_RelationalOperationElement_1__SqlGenerationContext_1__String_1_, joinStringsProcessor = processJoinStringsOperationForH2_JoinStrings_1__SqlGenerationContext_1__String_1_, @@ -46,11 +45,6 @@ function meta::relational::functions::sqlQueryToString::debugPrint::createDbExte ); } -function meta::relational::functions::sqlQueryToString::debugPrint::tabularFunctionProcessor(schema:String[1], functionName: String[1]):String[1] -{ - 'table('+ if($schema=='', | $functionName,| $schema+'.'+$functionName) + '())'; -} - function <> meta::relational::functions::sqlQueryToString::debugPrint::processJoinForDebugPrint(j:JoinTreeNode[1], dbConfig : DbConfig[1], format:Format[1], extensions:Extension[*]):String[1] { $j.join->match( diff --git a/legend-engine-xts-snowflakeApp/legend-engine-xt-snowflakeApp-pure/src/main/resources/core_snowflakeapp/tests/testSnowflakeAppGeneration.pure b/legend-engine-xts-snowflakeApp/legend-engine-xt-snowflakeApp-pure/src/main/resources/core_snowflakeapp/tests/testSnowflakeAppGeneration.pure index ed85680fd84..3a10e04ce53 100644 --- a/legend-engine-xts-snowflakeApp/legend-engine-xt-snowflakeApp-pure/src/main/resources/core_snowflakeapp/tests/testSnowflakeAppGeneration.pure +++ b/legend-engine-xts-snowflakeApp/legend-engine-xt-snowflakeApp-pure/src/main/resources/core_snowflakeapp/tests/testSnowflakeAppGeneration.pure @@ -71,15 +71,6 @@ function <> meta::external::function::activator::snowflakeApp::tests: assertSnowflakeArtifactForFunction(meta::external::function::activator::snowflakeApp::tests::simpleRelationalfunctionEnumParam_Gender_1__TabularDataSet_1_, $expected); } -function <> meta::external::function::activator::snowflakeApp::tests::testUdtfOnUdtf():Any[*] -{ - let result = meta::legend::compileLegendGrammar(readFile('/core_relational_snowflake/relational/tests/tabularFunctionModel.txt')->toOne()); - let func = $result->filter(f|$f->instanceOf(ConcreteFunctionDefinition)) - ->cast(@ConcreteFunctionDefinition)->filter(c| $c.name=='FetchChildrenViaSelfJoin__TabularDataSet_1_')->toOne(); - let expected = 'CREATE OR REPLACE SECURE FUNCTION %S.LEGEND_NATIVE_APPS.APP1() RETURNS TABLE ("FIRSTNAME" VARCHAR,"ID" INTEGER,"CHILDREN/AGE" INTEGER,"CHILDREN/ID" INTEGER,"CHILDREN/FIRSTNAME" VARCHAR) LANGUAGE SQL AS $$ select "root".firstname as "Firstname", "root".id as "Id", "parentandchildren_1".age as "Children/Age", "parentandchildren_1".id as "Children/Id", "parentandchildren_1".firstname as "Children/Firstname" from table(Org.ParentAndChildren()) as "root" left outer join table(Org.ParentAndChildren()) as "parentandchildren_1" on ("root".parentId = "parentandchildren_1".id) $$;'; - meta::external::function::activator::snowflakeApp::tests::assertSnowflakeArtifactForFunction($func, $expected); -} - function meta::external::function::activator::snowflakeApp::tests::simpleRelationalfunction():TabularDataSet[1] { PersonX.all()->filter(p|$p.firstName == 'haha')->project([col(p|$p.firstName, 'firstName'), col(p|$p.lastName, 'lastName')]) @@ -153,4 +144,3 @@ function meta::external::function::activator::snowflakeApp::tests::assertSnowfla let generatedQuery = if($extensions->isNotEmpty(),| $app->generateArtifact($extensions),|$app->generateArtifact()); assertEquals($expected, $generatedQuery); } -