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

Relation.structure() fails for TableSlice with ClassCastException #963

Closed
brainbytes42 opened this issue Aug 4, 2021 · 1 comment
Closed

Comments

@brainbytes42
Copy link
Contributor

Hi,

for a slice from a TableSliceGroup, a call to structure fails with an Exception:
java.lang.ClassCastException: class tech.tablesaw.api.DoubleColumn cannot be cast to class tech.tablesaw.api.IntColumn (tech.tablesaw.api.DoubleColumn and tech.tablesaw.api.IntColumn are in unnamed module of loader 'app')

This was the case for a table with different columns of "real data", but is the same for this following small example:

import tech.tablesaw.api.StringColumn;
import tech.tablesaw.api.Table;
import tech.tablesaw.table.TableSlice;
import tech.tablesaw.table.TableSliceGroup;

public class SliceTest {

    public static void main(String[] args) {

        Table table = Table.create(StringColumn.create("MyCol", "A", "A", "B"));

        TableSliceGroup sliceGroup = table.splitOn("MyCol");

        System.out.println("++++++++++ structure() for slice fails ++++++++++");

        for (TableSlice slice : sliceGroup.getSlices()) {
            System.out.println("slice: " + slice);
            System.out.println();
            try {
                System.out.print("slice.structure(): ");
                System.out.println(slice.structure()); // FAILS
            } catch (ClassCastException e) {
                System.out.println(e);
            }
            System.out.println();
        }

        System.out.println();
        System.out.println("++++++++++ ... but structure() for slices as tables works ++++++++++");

        for (Table tableListTable : sliceGroup.asTableList()) {
            System.out.println("tableListTable: " + tableListTable);
            System.out.println();

            System.out.println("tableListTable.structure(): ");
            System.out.println(tableListTable.structure());

            System.out.println();
        }

    }

}

I've tested it with Amazon Corretto 16 and tablesaw-core:0.38.2 / 0.38.3

lwhite1 added a commit that referenced this issue Aug 12, 2021
Moved the structure implementation from Table up to Relation, replacing the existing version there.
lwhite1 added a commit that referenced this issue Aug 12, 2021
Moved the structure implementation from Table up to Relation, replacing the existing version there.
@lwhite1
Copy link
Collaborator

lwhite1 commented Aug 12, 2021

fixed

@lwhite1 lwhite1 closed this as completed Aug 12, 2021
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

2 participants