DataFrameJoiner { public Table inner(Table... tables) { return inner(false, tables); } DataFrameJoiner(Table table, String... joinColumnNames); Table inner(Table... tables); Table inner(boolean allowDuplicateColumnNames, Table... tables); Table inner(Table table2, String col2Name); Table inner(Table table2, String[] col2Names); Table inner(Table table2, String col2Name, boolean allowDuplicateColumnNames); Table inner(Table table2, boolean allowDuplicateColumnNames, String... col2Names); Table fullOuter(Table... tables); Table fullOuter(boolean allowDuplicateColumnNames, Table... tables); Table fullOuter(Table table2, String col2Name); Table leftOuter(Table... tables); Table leftOuter(boolean allowDuplicateColumnNames, Table... tables); Table leftOuter(Table table2, String[] col2Names); Table leftOuter(Table table2, String col2Name); Table leftOuter(Table table2, boolean allowDuplicateColumnNames, String... col2Names); Table rightOuter(Table... tables); Table rightOuter(boolean allowDuplicateColumnNames, Table... tables); Table rightOuter(Table table2, String col2Name); Table rightOuter(Table table2, String[] col2Names); Table rightOuter(Table table2, boolean allowDuplicateColumnNames, String... col2Names);  }
@Test public void innerJoinWithDoubleBirdsCatsFishDouble() { Table joined = DOUBLE_INDEXED_BIRDS.joinOn("ID").inner(DOUBLE_INDEXED_CATS, DOUBLE_INDEXED_FISH); assertEquals(4, joined.columnCount()); assertEquals(1, joined.rowCount()); }
@Test public void innerJoinWithDoubleDogsCatsBirdsDouble() { Table joined = DOUBLE_INDEXED_FISH.joinOn("ID").inner(DOUBLE_INDEXED_CATS, DOUBLE_INDEXED_BIRDS); assertEquals(4, joined.columnCount()); assertEquals(1, joined.rowCount()); }
@Test public void innerJoinWithDoubleDogsCatsFishVarargs() { Table joined = DOUBLE_INDEXED_MICE.joinOn("ID").inner(DOUBLE_INDEXED_CATS, DOUBLE_INDEXED_FISH); assertEquals(4, joined.columnCount()); assertEquals(2, joined.rowCount()); }
@Test public void innerJoinWithDoublesSimple() { Table joined = DOUBLE_INDEXED_PEOPLE.joinOn("ID").inner(DOUBLE_INDEXED_DOGS); assertEquals(3, joined.columnCount()); assertEquals(3, joined.rowCount()); assertEquals(3, joined.column("ID").size()); }
@Test public void innerJoinWithDoubles() { Table joined = DOUBLE_INDEXED_PEOPLE.joinOn("ID").inner(DOUBLE_INDEXED_DOGS, "ID"); assertEquals(3, joined.columnCount()); assertEquals(3, joined.rowCount()); }
@Test public void innerJoinWithDuplicateColumnNames() { Table table1 = DUPLICATE_COL_NAME_DOGS.where(DUPLICATE_COL_NAME_DOGS.booleanColumn("Good").isTrue()); Table table2 = DUPLICATE_COL_NAME_DOGS.where(DUPLICATE_COL_NAME_DOGS.booleanColumn("Good").isFalse()); Table joined = table1.joinOn("ID").inner(table2, "ID", true); assertEquals(5, joined.columnCount()); assertEquals(4, joined.rowCount()); }
@Test public void innerJoin() { Table joined = SP500.joinOn("Date").inner(ONE_YEAR, "Date"); assertEquals(3, joined.columnCount()); assertEquals(5, joined.rowCount()); }
@Test public void innerJoinSingleColumn() { Table joined = SP500.select("Date").joinOn("Date").inner(ONE_YEAR.select("Date")); assertEquals(5, joined.rowCount()); assertEquals(1, joined.columnCount()); }
@Test public void innerJoinSingleColumnOnRight() { Table joined = SP500.joinOn("Date").inner(ONE_YEAR.select("Date")); assertEquals(5, joined.rowCount()); assertEquals(2, joined.columnCount()); }
@Test public void innerJoinMultipleColumnsAllColumnsInJoinKey() { Table table1 = Table.create(SP500.dateColumn("Date"), SP500.dateColumn("Date").copy().setName("Date2")); Table table2 = Table.create( ONE_YEAR.dateColumn("Date"), ONE_YEAR.dateColumn("Date").copy().setName("Date2")); Table joined = table1.joinOn("Date", "Date2").inner(table2); assertEquals(5, joined.rowCount()); assertEquals(2, joined.columnCount()); }
@Test public void innerJoinWithBoolean() { Table joined = DUPLICATE_COL_NAME_DOGS.joinOn("Good").inner(true, DUPLICATE_COL_NAME_DOGS.copy()); assertEquals(5, joined.columnCount()); assertEquals(32, joined.rowCount()); }
@Test public void innerJoinDuplicateKeysFirstTable() { Table joined = ANIMAL_NAMES.joinOn("Animal").inner(ANIMAL_FEED, "Animal"); assertEquals(3, joined.columnCount()); assertEquals(4, joined.rowCount()); }
@Test public void innerJoinDuplicateKeysSecondTable() { Table joined = ANIMAL_FEED.joinOn("Animal").inner(ANIMAL_NAMES, "Animal"); assertEquals(3, joined.columnCount()); assertEquals(4, joined.rowCount()); }
@Test public void innerJoinDuplicateKeysSecondTableWithTextColumn() { Table feed = ANIMAL_FEED.copy(); Table names = ANIMAL_NAMES.copy(); feed.replaceColumn("Animal", feed.stringColumn("Animal").asTextColumn()); TextColumn nameCol = names.stringColumn("Animal").asTextColumn(); nameCol = nameCol.where(Selection.withRange(0, feed.rowCount())); feed.replaceColumn("Animal", nameCol); Table joined = ANIMAL_FEED.joinOn("Animal").inner(ANIMAL_NAMES, "Animal"); assertEquals(3, joined.columnCount()); assertEquals(4, joined.rowCount()); }
@Test public void innerJoinStudentInstructorOnAge() { Table table1 = createSTUDENT(); Table table2 = createINSTRUCTOR(); Table joined = table1.joinOn("Age").inner(true, table2); assert (joined .columnNames() .containsAll(Arrays.asList("T2.ID", "T2.City", "T2.State", "T2.USID", "T2.GradYear"))); assertEquals(16, joined.columnCount()); assertEquals(14, joined.rowCount()); }
@Test public void joiningShouldNotMutateColNamesOnOriginalTable() { Table table1 = createSTUDENT(); Table table2 = createINSTRUCTOR(); List<String> originalColumns = table2.columns().stream().map(Column::name).collect(Collectors.toList()); table1.joinOn("Age").inner(true, table2); List<String> newColumns = table2.columns().stream().map(Column::name).collect(Collectors.toList()); assertEquals(originalColumns, newColumns); }
@Test public void innerJoinInstructorStudentOnAge() { Table table1 = createINSTRUCTOR(); Table table2 = createSTUDENT(); Table joined = table1.joinOn("Age").inner(true, table2); assert (joined .columnNames() .containsAll(Arrays.asList("T2.ID", "T2.City", "T2.State", "T2.USID", "T2.GradYear"))); assertEquals(16, joined.columnCount()); assertEquals(14, joined.rowCount()); }
@Test public void innerJoinStudentInstructorClassOnAge() { Table table1 = createSTUDENT(); Table table2 = createINSTRUCTOR(); Table table3 = createCLASS(); Table joined = table1.joinOn("Age").inner(true, table2, table3); assert (joined .columnNames() .containsAll( Arrays.asList("T2.ID", "T2.City", "T2.State", "T2.USID", "T2.GradYear", "T3.ID"))); assertEquals(24, joined.columnCount()); assertEquals(14, joined.rowCount()); }
@Test public void innerJoinStudentInstructorClassDeptHeadOnAge() { Table table1 = createSTUDENT(); Table table2 = createINSTRUCTOR(); Table table3 = createCLASS(); Table table4 = createDEPTHEAD(); Table joined = table1.joinOn("Age").inner(true, table2, table3, table4); assert (joined .columnNames() .containsAll( Arrays.asList( "T2.ID", "T2.City", "T2.State", "T2.USID", "T2.GradYear", "T3.ID", "T4.ID", "T4.First", "T4.Last", "T4.City", "T4.State"))); assertEquals(30, joined.columnCount()); assertEquals(14, joined.rowCount()); }
@Test public void innerJoinStudentInstructorDeptHeadOnStateAge() { Table table1 = createSTUDENT(); Table table2 = createINSTRUCTOR(); Table table3 = createDEPTHEAD(); Table joined = table1.joinOn("State", "Age").inner(true, table2, table3); assert (joined .columnNames() .containsAll( Arrays.asList( "T2.ID", "T2.City", "T2.USID", "T2.GradYear", "T3.ID", "T3.First", "T3.Last", "T3.City"))); assertEquals(20, joined.columnCount()); assertEquals(1, joined.rowCount()); }
@Test public void innerJoinStudentInstructorOnStateAge() { Table table1 = createSTUDENT(); Table table2 = createINSTRUCTOR(); Table joined = table1.joinOn("State", "Age").inner(true, table2); assertEquals(15, joined.columnCount()); assertEquals(3, joined.rowCount()); }
@Test public void innerJoinStudentInstructorOnStateAgeGradYear() { Table table1 = createSTUDENT(); Table table2 = createINSTRUCTOR(); Table joined = table1.joinOn("State", "Age", "GradYear").inner(true, table2); assertEquals(14, joined.columnCount()); assertEquals(2, joined.rowCount()); }
@Test public void innerJoinHouseBoatOnBedroomsOwner() { Table table1 = createHOUSE(); Table table2 = createBOAT(); Table joined = table1.joinOn("Bedrooms", "Owner").inner(table2, new String[] {"Bedrooms", "Owner"}); assertEquals(6, joined.columnCount()); assertEquals(2, joined.rowCount()); assertEquals(2, joined.column("Bedrooms").size()); }
@Test public void innerJoinHouseBoatOnStyleTypeBedroomsOwner() { Table table1 = createHOUSE(); Table table2 = createBOAT(); Table joined = table1 .joinOn("Style", "Bedrooms", "Owner") .inner(table2, new String[] {"Type", "Bedrooms", "Owner"}); assertEquals(5, joined.columnCount()); assertEquals(1, joined.rowCount()); }
@Test public void innerJoinStudentInstructorOnStateName() { Table table1 = createSTUDENT(); Table table2 = createINSTRUCTOR(); Table joined = table1.joinOn("State", "FirstName").inner(table2, true, "State", "First"); assertEquals(15, joined.columnCount()); assertEquals(5, joined.rowCount()); }
@Test public void innerJoinOnAge() { Table table1 = createANIMALHOMES(); Table table2 = createDOUBLEINDEXEDPEOPLENameHomeAgeMoveInDate(); Table joined = table1.joinOn("Age").inner(table2, "Age", true); assertEquals(9, joined.columnCount()); assertEquals(18, joined.rowCount()); }
@Test public void innerJoinAnimalPeopleOnAge() { Table table1 = createANIMALHOMES(); Table table2 = createDOUBLEINDEXEDPEOPLENameHomeAgeMoveInDate(); Table joined = table1.joinOn("Age").inner(true, table2); assertEquals(9, joined.columnCount()); assertEquals(18, joined.rowCount()); }
@Test public void innerJoinAnimalTreeOnAge() { Table table1 = createANIMALHOMES(); Table table2 = createTREE(); Table joined = table1.joinOn("Age").inner(true, table2); assertEquals(7, joined.columnCount()); assertEquals(8, joined.rowCount()); }
@Test public void innerJoinAnimalPeopleTreeOnAge() { Table table1 = createANIMALHOMES(); Table table2 = createDOUBLEINDEXEDPEOPLENameHomeAgeMoveInDate(); Table table3 = createTREE(); Table table4 = createFLOWER(); Table joined = table1.joinOn("Age").inner(true, table2, table3, table4); assert (joined .columnNames() .containsAll( Arrays.asList( "T2.Name", "T2.HOME", "T2.MoveInDate", "T3.Name", "T3.Home", "T4.Name", "T4.Home", "Color"))); assertEquals(14, joined.columnCount()); assertEquals(18, joined.rowCount()); }
@Test public void innerJoinAnimalPeopleTreeOnAgeHome() { Table table1 = createANIMALHOMES(); Table table2 = createDOUBLEINDEXEDPEOPLENameHomeAgeMoveInDate(); Table table3 = createTREE(); Table table4 = createFLOWER(); Table joined = table1.joinOn("Age", "Home").inner(true, table2, table3, table4); assert (joined .columnNames() .containsAll( Arrays.asList( "Animal", "Name", "Home", "Age", "MoveInDate", "ID", "T2.Name", "T2.MoveInDate", "T3.Name", "T4.Name", "Color"))); assertEquals(11, joined.columnCount()); assertEquals(2, joined.rowCount()); }
@Test public void innerJoinOnNameHomeAge() { Table table1 = createANIMALHOMES(); Table table2 = createDOUBLEINDEXEDPEOPLENameHomeAgeMoveInDate(); Table joined = table1.joinOn("Name", "Home", "Age").inner(true, table2); assertEquals(7, joined.columnCount()); assertEquals(1, joined.rowCount()); }
@Test public void innerJoinOnAllMismatchedColNames() { Table table1 = createANIMALHOMES(); Table table2 = createDOUBLEINDEXEDPEOPLENicknameDwellingYearsMoveInDate(); Table joined = table1.joinOn("Name", "Home", "Age").inner(table2, true, "Nickname", "Dwelling", "Years"); assertEquals(7, joined.columnCount()); assertEquals(2, joined.rowCount()); }
@Test public void innerJoinOnPartiallyMismatchedColNames() { Table table1 = createANIMALHOMES(); Table table2 = createDOUBLEINDEXEDPEOPLENameDwellingYearsMoveInDate(); Table joined = table1.joinOn("Name", "Home", "Age").inner(table2, true, "Name", "Dwelling", "Years"); assert (joined.columnNames().containsAll(Arrays.asList("Name", "Home", "Age"))); assertEquals(7, joined.columnCount()); assertEquals(2, joined.rowCount()); }
@Test public void innerJoinOnAgeMoveInDate() { Table table1 = createANIMALHOMES(); Table table2 = createDOUBLEINDEXEDPEOPLENameHomeAgeMoveInDate(); Table joined = table1.joinOn("Age", "MoveInDate").inner(true, table2); assertEquals(8, joined.columnCount()); assertEquals(3, joined.rowCount()); }
@Test public void innerJoinFootballSoccerOnPlayDate() { Table table1 = createFOOTBALLSCHEDULE(); Table table2 = createSOCCERSCHEDULE(); Table joined = table1.joinOn("PlayDate").inner(true, table2); assertEquals(8, joined.columnCount()); assertEquals(5, joined.rowCount()); }
@Test public void innerJoinFootballSoccerOnPlayTime() { Table table1 = createFOOTBALLSCHEDULE(); Table table2 = createSOCCERSCHEDULE(); Table joined = table1.joinOn("PlayTime").inner(true, table2); assertEquals(8, joined.columnCount()); assertEquals(3, joined.rowCount()); }
@Test public void innerJoinFootballSoccerOnPlayDatePlayTime() { Table table1 = createFOOTBALLSCHEDULE(); Table table2 = createSOCCERSCHEDULE(); Table joined = table1.joinOn("PlayDate", "PlayTime").inner(true, table2); assertEquals(7, joined.columnCount()); assertEquals(2, joined.rowCount()); }
@Test public void innerJoinFootballSoccerOnPlayDatePlayDateTime() { Table table1 = createFOOTBALLSCHEDULEDateTime(); Table table2 = createSOCCERSCHEDULEDateTime(); Table joined = table1.joinOn("PlayDateTime").inner(true, table2); assertEquals(10, joined.columnCount()); assertEquals(2, joined.rowCount()); }
@Test public void innerJoinFootballSoccerOnSeasonRevenue() { Table table1 = createFOOTBALLSCHEDULEDateTime(); Table table2 = createSOCCERSCHEDULEDateTime(); Table joined = table1.joinOn("SeasonRevenue", "AllTimeRevenue").inner(true, table2); assertEquals(9, joined.columnCount()); assertEquals(1, joined.rowCount()); }
@Test public void differentColumnTypes() { Table table1 = STRING_INDEXED_PEOPLE; Table table2 = DOUBLE_INDEXED_PEOPLE; Assertions.assertThrows( IllegalArgumentException.class, () -> { table1.joinOn("ID").inner(table2); }); }
@Test public void innerJoinEmptyLeftTable() { Table leftTable = Table.create(StringColumn.create("Animal")); Table joined = leftTable.joinOn("Animal").inner(ANIMAL_NAMES); assertEquals(0, joined.rowCount()); for (Column<?> column : joined.columnArray()) { assertEquals(0, column.size()); } }
@Test public void leftOuterJoinEmptyLeftTable() { Table leftTable = Table.create(StringColumn.create("Animal")); Table joined = leftTable.joinOn("Animal").inner(ANIMAL_NAMES); assertEquals(0, joined.rowCount()); for (Column<?> column : joined.columnArray()) { assertEquals(0, column.size()); } }