This software was funded by the European Union.
VTL Processing is a .NET Core library for translating VTL (see https://sdmx.org/?page_id=5096) expressions into various target languages. The generated code can be then executed in a data processing environment to perform data validation or transformation. The library is DI-friendly and comes with built in support for .NET IOC container.
For full documentation see https://statisticspoland.github.io/VTL-Processing
|
Warning
|
docs is still work in progress |
Just use the Translator class:
Translator translator = new Translator((configure) =>
{
configure.AddTsqlTarget((config) =>
{
config.AddComments();
});
});
translator.DataModels.AddJsonModel(
$"{Directory.GetCurrentDirectory()}\\DataModel.json");
translator.DataModels.DefaultNamespace = "JsonTest";
translator.EnvironmentMapper.Mapping = new Dictionary<string, string>()
{
{ "JsonTest", "[SqlDatabase]." }
};
string vtlSource = "Z := X + Y";
string tsqlResult = translator.Translate(vtlSource, "TSQL");This will result in the following target T-SQL code:
-- Script generated: 23.07.2021 12:13:04
BEGIN TRANSACTION
IF OBJECT_ID (N'tempdb..#Z', N'U') IS NOT NULL
DROP TABLE #Z
-- Raw: Z := X + Y
SELECT * INTO #Z FROM (
SELECT
ds1.Id1,
ds2.Id2,
ds1.Me1 + ds2.Me1 AS Me1,
ds1.Me2 + ds2.Me2 AS Me2,
(SELECT MIN(VALUE) FROM
(SELECT ds1.At1 AS VALUE UNION
SELECT ds2.At1 AS VALUE) AS t) AS At1
FROM [SqlDatabase].X AS ds1
INNER JOIN [SqlDatabase].Y AS ds2
ON
ds1.Id1 = ds2.Id1
) AS t
COMMIT TRANSACTION
GO