Skip to content

DataFrame distinct with multiple columns in the selector is not working if the name of the columns is variable #155

@marcodisa

Description

@marcodisa

Hi, I'm not sure if this is the proper section to post this question,
First of all I’d like to congratulate you on the amazing work you’ve done with Data Forge npm and Data Forge Notebook. It’s a very extraordinary package and the Notebook is an extremely useful tool.
I’m seriously considering the upgrade to the pro version for my further projects.

Anyway, I’m stuck on a DataFrame distinct with two parameters in the selector.

If I run the code below it perfectly does what I want, “filiale” and “CAP” are two columns of df.

const safeJoinChar = '$';
var distinct_join = df.distinct(value => [value.filiale, value.CAP].join(safeJoinChar));
console.log(distinct_join.toString());

Actually I need to put the execution of the select distinct into a loop. I need the select distinct of every column with all the other columns, two columns at a time.
Long story short, I have a loop that in every iteration assigns the value to two variables serie1_name and serie2_name, in every iteration I correctly get my two variables like the code below.
Now I need the dataframe distinct to work with variable names not with the explicit names of the columns.
How the code below should be to work fine with variable column names?

var serie1_name = "filiale";
var serie2_name = "CAP";
const safeJoinChar = '$';

var distinct_join = df.distinct(value => [value.serie1_name, value.serie2_name].join(safeJoinChar));

console.log(distinct_join.toString());

I’ve tried many ways to make it work but I wasn’t able to handle it myself.
Is there something I’m missing out?
Can I get any hints or suggestions?

Thank you very much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions