Dataframe transforms and Parquet save operators#2031
Merged
Conversation
rolandwalker
force-pushed
the
RW/dataframe-post-processing
branch
from
July 21, 2026 10:43
2592d9e to
2376033
Compare
rolandwalker
requested review from
amjith and
scottnemes
and removed request for
amjith and
scottnemes
July 21, 2026 10:43
rolandwalker
force-pushed
the
RW/dataframe-post-processing
branch
from
July 21, 2026 10:47
2376033 to
1ac8553
Compare
scottnemes
reviewed
Jul 21, 2026
| try: | ||
| import polars as pl | ||
| except ImportError as exc: | ||
| raise PolarsTransformError("Polars transforms require Polars to be installed.'") from exc |
Contributor
There was a problem hiding this comment.
Extra single quote at the end here and same thing just below
scottnemes
approved these changes
Jul 21, 2026
scottnemes
left a comment
Contributor
There was a problem hiding this comment.
Looks good! Left one nit comment for string fixes
Add a trailing operator .| which allows applying arbitrary dataframe transforms with Polars. This is similar to the $| operator, except that normal tabular output is maintained, so long as the Polars expression also returns a DataFrame or Series. Add a trailing operator .> which saves output to a Parquet file. This is similar to the $> operator for shell redirection. Together these features are intended to make mycli more friendly to Data Science practitioners, lowering the boundaries between the CLI/REPL and notebook modes of working. In many cases, dataframe transformations may be achievable in plain SQL, but for many practitioners, dataframes are the preferred approach. In other cases, there are computations which are achievable in dataframes but not in SQL. Medians are a simple example. There are performance implications of using the dataframe transform: the entire SQL result must be fetched and loaded into memory. Counter to the familiarity argument above, the .| operator supplies a Polars dataframe rather than a Pandas dataframe. While Pandas is the industry standard, Polars is growing, and should be familiar enough to be a workable alternative. Polars is sometimes a bit faster, and usually far more memory-efficient. But the reason it is chosen here over Pandas is that the dependency chain for mycli is simpler. Polars is also configured as an optional dependency in pyproject.toml.
rolandwalker
force-pushed
the
RW/dataframe-post-processing
branch
from
July 21, 2026 18:07
1ac8553 to
9b5e6ff
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add a trailing operator
.|which allows applying arbitrary dataframe transforms with Polars. This is similar to the$|operator, except that normal tabular output is maintained, so long as the Polars expression also returns aDataFrameorSeries.Add a trailing operator
.>which saves output to a Parquet file. This is similar to the$>operator for shell redirection.Together these features are intended to make mycli more friendly to Data Science practitioners, lowering the boundaries between the CLI/REPL and notebook modes of working.
In many cases, dataframe transformations may be achievable in plain SQL, but for many practitioners, dataframes are the preferred approach. In other cases, there are computations which are achievable in dataframes but not in SQL. Medians are a simple example.
There are performance implications of using the dataframe transform: the entire SQL result must be fetched and loaded into memory.
Counter to the familiarity argument above, the
.|operator supplies a Polars dataframe rather than a Pandas dataframe.While Pandas is the industry standard, Polars is growing, and should be familiar enough to be a workable alternative. Polars is sometimes a bit faster, and usually far more memory-efficient. But the reason it is chosen here over Pandas is that the dependency chain for mycli is simpler.
Polars is also configured as an optional dependency in
pyproject.toml.There is more extensive documentation of the functionality in the PR.
Simple example showing a transform which returns a
DataFrame, which is then rendered as usual:Checklist
changelog.mdfile.AUTHORSfile (or it's already there).