InseeFrLab / Trevas-Jupyter

Jupyter notebook providing VTL support through Trevas engine
MIT License
2 stars 2 forks source link

Allow specifying options in load/write functions #108

Open jornfranke opened 5 months ago

jornfranke commented 5 months ago

Currently, one can load/write data only with specific default options without being able to customize them.

For instancce, in loadCsv or writeCsv I cannot specify a different separator from ";". There are many other options relevant for reading/writing CSV files.

loadParquet/writeParquet does not allow to specify options, such as compression (cf. here).

I propose to have additional functions, e.g. loadCsvWithParameters that takes as input the path and a Map<String,String> which allows to specify any options. I am not exactly sure how one can pass a Map<String,String> in VTL initialized with data. Alternatively one can provide simply a "config" Dataset.class which contains in a dataset with two columns (key,value).

NicoLaval commented 5 months ago

Relevant point. For now, it's hardcoded with a simple configuration, and sure it's not satisfactory.

Defining the Map in the VTL script seems to be impossible.

I imagine two ways to enable custom configuration:

I suggest we discuss this during our future call.

NicoLaval commented 5 months ago

Hi @jornfranke,

We discussed the possibilities with @hadrienk:

define operator read(url string, sep string default ";", delimiter string default "'", header boolean default true)
returns dataset is
readCSV(sep, delimiter, header)
end operator;

And instantiate with read("path", _, _, false); for instance.

At this point, parameters are only positional in VTL, which would give an ugly syntax if we want to expose many options as parameters (see this issue posted on the VTL TF repo).

What do you think?

jornfranke commented 5 months ago

Thanks for the feedback. We did internally some workaround and will look into the second option you propose. The first option would probably makes sense once Trevas supports it.