Skip to content

Commit

Permalink
fix lineage for calendar functions (#3072)
Browse files Browse the repository at this point in the history
  • Loading branch information
AFine-gs authored Sep 5, 2024
1 parent 7e0641f commit 25cf503
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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 <<test.Test>> 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);

}
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
);
Expand All @@ -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.')
);
Expand Down

0 comments on commit 25cf503

Please sign in to comment.