Skip to content

Fix select-col, delete-col and reorder-col; release 2.1.1 - #93

Merged
clojure-finance merged 1 commit into
2.x.xfrom
fix-column-functions
Oct 20, 2026
Merged

clojure-finance merged 1 commit into
2.x.xfrom
fix-column-functions

Conversation

@buehlmaier

Copy link
Copy Markdown
Collaborator

Fixes select-col, delete-col and reorder-col, and releases 2.1.1.

Bugs

  • select-col and delete-col did nothing. They recorded the deleted columns, but since 1.1.0 (January 2022) compute no longer read that record, so every column was still written and get-col-names still listed it.
  • reorder-col rebuilt the column descriptions, which dropped every earlier operate on existing columns. Earlier filters and types stayed at their old positions, so they applied to whichever column moved there. The result was silently wrong output (e.g. a filter on Salary ending up on Department and returning no rows) or a rejected reorder with a misleading error. It also rejected columns created by operate.

Fix

The three functions now only choose which columns compute writes and in which order. They store a list of output columns on the dataframe, and rollback covers it. Operations, filters and types are not touched, so they stay on their columns.

  • get-col-names, compute, preview and print-df follow the chosen columns. An explicit :select / :exclude picks from them.
  • Joins use each side's chosen columns, also when the join swaps sides internally.
  • A filter, operate, group-by, aggregate or join key can still use a deleted column, the same as with a column left out by :select.
  • A column created by operate after a delete or reorder is added at the end.
  • Bad input is rejected before anything changes: unknown names, deleting every column, a reorder-col list that isn't every column exactly once, and any of the three after group-by or aggregate (use :select there).
  • preview :format true applied formatters by position, which became wrong once columns can be left out; it now applies them by column.

The unused setColInfo / setRowInfo code is removed.

Tests

Five new tests in regression_test.clj: reorder after set-type, operate, filter and a formatter; delete and select with filters on deleted columns and new columns; aggregate on a deleted column; joins on both sides, swapped and with :select, on disk and in memory; and the rejected inputs. Against the old code they give 12 failures and 2 errors. Suite: 60 tests / 306 assertions, green on JDK 25.

Version bumped to 2.1.1 in project.clj and the README install snippets.

select-col and delete-col had no effect, and reorder-col dropped earlier
operations and moved filters and types onto other columns. All three now
set the dataframe's output columns and their order, which compute,
preview, print-df and joins follow, without touching operations, filters
or types.
@clojure-finance
clojure-finance merged commit 602e3db into 2.x.x Oct 20, 2026
3 checks passed
@buehlmaier
buehlmaier deleted the fix-column-functions branch October 20, 2026 16:43
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

Successfully merging this pull request may close these issues.

2 participants