Skip to main content

Hi community,

we have the below (screenshot) calendar identifier in AIMMS and are writing data indexed over iWeek (elements of the form "w44-2024") to Parquet files using DEX. Now, whenever DEX does this for us, these elements are written to the Parquet file as "2024-10-28 01:00:00" instead, looking like a datetime object being the first time instant of this week. Similarly, for months, a datetime object is written being the first time instant of this month. However, when reading in these Parquet files again using DEX, with the same mapping, these month elements are read in correctly while the week elements are not. I.e., the element "2024-10-28 01:00:00" above cannot be mapped back again to "w44-2024". 

We would be interested to hear any best practices regarding reading and writing calendar elements using DEX and if we are overlooking something here. 

Thanks!

 

 

Dear @danileidelmeijer 

 

I tried reproducing your issue, but was not successful.

This is what I did:

 

DeclarationSection __unnamed {
StringParameter sp_start {
Definition: "2024-01-01 00:00:00";
}
StringParameter sp_finish {
Definition: "2024-12-31 00:00:00";
}
Calendar calWeekGlobal {
Index: iWeek;
Unit: week;
BeginDate: sp_start;
EndDate: sp_finish;
TimeslotFormat: "w%W-%C%Y";
}
Parameter p_data {
IndexDomain: iWeek;
dex::ColumnName: column;
dex::Dataset: dataset;
dex::TableName: table;
}
}


Procedure pr_addData {
Body: {
p_data(iWeek) :=
data
{ w01-2024 : 86, w02-2024 : 97, w03-2024 : 39, w04-2024 : 55, w05-2024 : 77, w06-2024 : 25, w07-2024 : 93,
w08-2024 : 36, w09-2024 : 74, w10-2024 : 86, w11-2024 : 30, w12-2024 : 77, w13-2024 : 76, w14-2024 : 5,
w15-2024 : 61, w16-2024 : 57, w17-2024 : 96, w18-2024 : 27, w19-2024 : 49, w20-2024 : 76, w21-2024 : 69,
w22-2024 : 80, w23-2024 : 9, w24-2024 : 58, w25-2024 : 68, w26-2024 : 43, w27-2024 : 35, w28-2024 : 9,
w29-2024 : 72, w30-2024 : 58, w31-2024 : 73, w32-2024 : 60, w33-2024 : 75, w34-2024 : 96, w35-2024 : 40,
w36-2024 : 24, w37-2024 : 24, w38-2024 : 9, w39-2024 : 58, w40-2024 : 2, w41-2024 : 72, w42-2024 : 51,
w43-2024 : 66, w44-2024 : 72, w45-2024 : 64, w46-2024 : 41, w47-2024 : 4, w48-2024 : 73, w49-2024 : 66,
w50-2024 : 99, w51-2024 : 47, w52-2024 : 73, w01-2025 : 53 };
}
}


Procedure pr_export {
Body: {
empty p_data;
pr_addData;
dex::GenerateDatasetMappings;
dex::ReadAllDEXMappings;
dex::WriteToFile(
dataFile : "out.parquet",
mappingName : "Generated/dataset-table-Parquet",
pretty : 1);
}
}


Procedure pr_import {
Body: {
empty p_data;
FileCopy(
"out.parquet" ,
"in.parquet",
confirm : 0);
dex::GenerateDatasetMappings;
dex::ReadAllDEXMappings;
dex::ReadFromFile(
dataFile : "in.parquet",
mappingName : "Generated/dataset-table-Parquet",
emptyIdentifiers : 0,
emptySets : 0,
resetCounters : 0);
}
}

 

Which is:

  • Created a calendar with weeks and a simple data parameter and a data filler procedure
  • Created an export procedure to Parquet
  • Created an import procedure from Parquet

I can run the export and get a parquet file that look like this:

 

Then, when I import it back in, after emptying the p_data parameter, the data is correctly imported into the weeks as expected:

Maybe you can tweak the attached project to reproduce your issue.


@danileidelmeijer 

What would you expect? Do you have a preference to have the literal week names from the model being used rather than a date?

 


@luispinto thanks for your help! I tried tweaking your attached project to reproduce the issue but was unsuccessful. 

Would it be an idea if I shared through some safe way our project folder including a .data file and our .parquet file? This project contains a test procedure I’ve included with which the problem can be reproduced. 

@MarcelRoelofs for me personally it makes sense this way but I am mostly interested in the data being read in correctly the way we’ve also written the data to parquet using DEX.


Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator