Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

summarize() multiple columns return columns in random order #1246

Open
cashlo opened this issue Dec 19, 2023 · 0 comments
Open

summarize() multiple columns return columns in random order #1246

cashlo opened this issue Dec 19, 2023 · 0 comments

Comments

@cashlo
Copy link

cashlo commented Dec 19, 2023

I don't really know how is the columns ordered after a summarize() my expectation is in the order of:

  1. In the order of passed columnNames
  2. In the order of the original table
  3. In alphabetical order

But it seems to be in random order, and the column name seems to be a factor?

Here's a short example:

public Table createMockTable(String metricName1, String metricName2) {
    Table mockTable = Table.create()
            .addColumns(
                      StringColumn.create("id"), 
                      LongColumn.create(metricName1), 
                      LongColumn.create(metricName2)
);

    Row row1 = mockTable.appendRow();
    row1.setString("id", "123");
    row1.setLong(metricName1, 123);
    row1.setLong(metricName2, 234);

    return mockTable
            .summarize(List.of(metricName1, metricName2), AggregateFunctions.sum)
            .by("id");
}

@Test
void wat() {
    Table mockTable1 = createMockTable("metric1", "metric2");
    Table mockTable2 = createMockTable("metricf1", "metricf2");

    System.out.println(mockTable1.print());
    System.out.println(mockTable2.print());
}

And the result is:

               null summary                
 id   |  Sum [metric1]  |  Sum [metric2]  |
-------------------------------------------
 123  |            123  |            234  |
                null summary                 
 id   |  Sum [metricf2]  |  Sum [metricf1]  |
---------------------------------------------
 123  |             234  |             123  |

I don't know if this is expected, if it is I can't seems to find this on the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant