From 25cf5034aaf7c9ea58d5e135213f8a37a9375e23 Mon Sep 17 00:00:00 2001 From: AFine-gs <69924417+AFine-gs@users.noreply.github.com> Date: Thu, 5 Sep 2024 18:42:23 -0400 Subject: [PATCH] fix lineage for calendar functions (#3072) --- .../tests/lineageTests.pure | 31 +++++++++++++++++++ .../calendarAggregationPureToSQL.pure | 4 +-- 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/tests/lineageTests.pure diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/tests/lineageTests.pure b/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/tests/lineageTests.pure new file mode 100644 index 00000000000..177eb0349d2 --- /dev/null +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/tests/lineageTests.pure @@ -0,0 +1,31 @@ +import meta::analytics::lineage::graph::*; +import meta::relational::extension::*; +import meta::pure::functions::date::calendar::*; +import meta::relational::tests::functions::pureToSqlQuery::calendarAggregations::*; +// 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. + +function <> meta::analytics::lineage::test::relational::calendarAggregations():Boolean[1] +{ + let r = meta::analytics::lineage::computeLineage(| Employee.all() + ->groupBy( + [p|$p.hireDate], + [ agg(p | annualized($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], + ['includedDate','annualized']) + ->filter(x | isNotEmpty($x.getNumber('annualized'))) + ->restrict(['includedDate']) + ,EmployeeMapping, meta::external::store::relational::tests::testRuntime(), relationalExtensions()); + assertSameElements(['Lambda','tb_EmployeeDatabasedefaultEmployeeTable','db_EmployeeDatabase'], $r.databaseLineage.nodes.data.id); + +} \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/calendarAggregation/calendarAggregationPureToSQL.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/calendarAggregation/calendarAggregationPureToSQL.pure index 26ba9dd9119..bf04adc055e 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/calendarAggregation/calendarAggregationPureToSQL.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/calendarAggregation/calendarAggregationPureToSQL.pure @@ -46,7 +46,7 @@ function meta::relational::functions::pureToSqlQuery::calendarAggregations::inse let join = ^Join(name='calendarJoin' +$nodeId, aliases=[pair($leftAlias,$rightAlias),pair($rightAlias,$leftAlias)], operation=[^DynaFunction(name = 'equal', parameters=[ ^TableAliasColumn(alias=$leftAlias , column=$dateColCursor.select.columns->cast(@TableAliasColumn).column->toOne()), - ^TableAliasColumn(alias=$rightAlias, column=^Column(name = 'date', type = ^meta::relational::metamodel::datatype::Date()) ) + ^TableAliasColumn(alias=$rightAlias, column=^Column(owner = meta::relational::functions::database::tableReference(CalendarDatabase,'LegendCalendarSchema',$calendarTableName), name = 'date', type = ^meta::relational::metamodel::datatype::Date()) ) ]) ]->cast(@Operation)->toOne('First parameter should be one date column.') ); @@ -55,7 +55,7 @@ function meta::relational::functions::pureToSqlQuery::calendarAggregations::inse let joinEnd = ^Join(name='calendarEndJoin'+$endDate->buildUniqueName(true, $extensions)+$nodeId, aliases=[pair($leftAlias,$rightAlias),pair($rightAlias,$leftAlias)], operation=[^DynaFunction(name = 'equal', parameters=[ $endDate, - ^TableAliasColumn(alias=$rightAlias, column=^Column(name = 'date', type = ^meta::relational::metamodel::datatype::Date()) ) + ^TableAliasColumn(alias=$rightAlias, column=^Column(owner = meta::relational::functions::database::tableReference(CalendarDatabase,'LegendCalendarSchema',$calendarTableName), name = 'date', type = ^meta::relational::metamodel::datatype::Date()) ) ]) ]->cast(@Operation)->toOne('First parameter should be one date column.') );