Source-level breaking changes between MoonFrame releases. Pre-1.0, breaking changes ride the minor version. The feature history behind each release lives in the GitHub release notes, written when the release is cut; the per-symbol reference — generated from the docstrings — is on mooncakes.io and GitHub Pages.
Source-level note:
DataTypegainedList(element)andStruct(schema), andScalargainedList(ListValue)andStruct(StructValue), which makes an exhaustivematchover either enum fail to compile until the variants are handled; amatchwhose other variants are handled by a catch-all_arm needs no change.ListValue,FieldValue, andStructValue— the payloads — are new public types on the facade. A struct's fields are aSchema; a struct column with no field cannot be built (the value itself may be empty).- Arrow IPC joins the facade:
read_ipc/parse_ipc/write_ipc,scan_ipc/sink_ipc, and the option typesIpcCompression/IpcFormattheir optional parameters take. No existing call changes. write_sql,read_sql_table, andscan_sqljoin the facade, over the moondb contractread_sqlalready rides, with the option enumSqlIfExiststhatwrite_sqltakes. No existing call changes.- Excel joins the facade:
read_excel/parse_excel/excel_sheets/write_excel, and the option typesExcelReadOptions/ExcelWriteOptionstheir optional parameters take. No existing call changes. - Avro joins the facade:
read_avro/parse_avro/write_avro, and the option enumAvroCodecthatwrite_avrotakes. No existing call changes. - Stata joins the facade:
read_stata/parse_stata/write_stata, over packages the module already depends on. No existing call changes. - XML joins the facade:
read_xml/parse_xml/write_xml/format_xml. No existing call changes. - HTML tables join the facade:
read_html/parse_html, which answer a frame a table. No existing call changes. - SAS joins the facade:
read_sas/parse_sas/write_sas, over packages the module already depends on. No existing call changes. - SPSS system files join the facade:
read_spss/parse_spss, read only, over packages the module already depends on. No existing call changes. - ORC files join the facade:
read_orc/parse_orc, read only, over packages the module already depends on. No existing call changes. - Iceberg tables join the facade:
read_iceberg, read only, over packages the module already depends on. No existing call changes. - Delta Lake tables join the facade:
read_delta, read only, over packages the module already depends on. No existing call changes. - HDF5 files join the facade:
read_hdf/hdf_keys, read only, over packages the module already depends on. No existing call changes. - Lance datasets join the facade:
read_lance, read only, over packages the module already depends on. No existing call changes. - MoonFrame depends on
gaato/lz4,gaato/zstd,gaato/snappy,gaato/crc,moonbit-community/flate, andMilky2018/xml: the LZ4 / Zstandard / snappy codecs, the CRC-32 behind a snappy block's checksum, the raw DEFLATE an Avro block goes through, and the event reader and escaper the XML interchange rides — the last declaring no backends and asking for none. The three codecs declare the backends they build for, andmoonasks a package that depends on one declaring them to declare its own: MoonFrame's packages name the setmoon.modalready names, and a package importing the facade is asked the same — onesupported_targetsline in itsmoon.pkganswers the advisory.
What changed on main since 0.9.0:
-
Parquet files with more than one row group now read (0.9 refused them with
Unsupported); a column's cells concatenate across the groups in their declared order.write_parquetgainsrow_group_rows~(default0= the whole frame as one row group, the 0.9 layout). -
The slice pushdown pass now sinks a
head/tail/sliceinto ascan_parquetleaf — the row groups outside the window are skipped outright, andexplain(optimized=true)renders the absorbed window as aWINDOW …suffix on theSCAN_PARQUETline. The surviving rows are exactly the eager read's; a page-level parse refusal confined to a skipped group no longer surfaces, the same skipping trade the projection pushdown already makes for dropped columns. The text scans keep their window as a plan node above the read. -
collectexecutes tree-shaped plans through a batch-wise pipeline — same rows, same order, same first error as before; what changes is where memory is spent (a plan whose verbs all ride the flow answers batch by batch, and a row-global verb materialises its input as it always did). A plan sharing oneLazyFrameacross both sides of a join keeps the previous node-by-node executor. -
LazyFrame::collect_batchesjoins the facade (with itsBatchStreamanswer): the same optimised plan, handed to the consumer batch by batch — stacking the batches equalscollect, and stopping the stream stops the read. -
Every pipeline's batches now pass a morsel row cap on their way out of the source, so a source whose own batches run coarse (a textual source's whole-read batch, a wide row group) answers in bounded windows; the cap is an internal shape, and batch boundaries carry no size promise.
-
The positional windows stream:
head/tail/slice(forward bounds),gather_every, andwith_row_indexride the flow carrying their place across batch boundaries (a trailing window holds no more than its ownnrows), flushing their tail at the drain — cell for cell and row for row the eager verbs' answers. The far-end shapes (a negative bound, a negative offset, a stride under validation) keep the whole-frame path. -
sink_parquet/sink_csvjoin the facade: a plan's streaming face turned to a file — the execution rides the pipeline batch by batch and the encoded bytes land in one write (the platform's whole-file write, not an incrementally flushed handle).sink_csvis byte-for-byteformat_csv(collect());sink_parquetlays one row group per batch (split inside a batch atrow_group_rows~), with the schema and the decimal interchange window fixed by the first batch. -
sink_json/sink_ndjsonjoin the facade: the same streaming face turned to a JSON records file or an NDJSON file.sink_jsonis byte-for-byteformat_json(collect()), the batches' records sharing one top-level array;sink_ndjsonis byte-for-byteformat_ndjson(collect()). Both write through the file writerwrite_json/write_ndjsonuse, so a.gzpath is compressed the same way and an unpaired surrogate is refused with the same error. -
PartitionByjoins the facade, andsink_parquet/sink_csv/sink_ipc/sink_ndjsontake it aspartition: a plan's rows go to files under a directory — one a distinct value of the key columns,column=valuea level, or so many rows a file — each file reading back as the sink's own rows for that partition. A sink called without it writes one file as before. No existing call changes. -
read_sqljoins the facade over the moondb contract: any moondb driver (the in-memoryMockDriverships with moondb; moonsqlite / moonpostgres / moondb's other drivers plug in the same way) answers a query as a frame, the column dtypes following the cells (TimeandNumerictexts parse intoTimestamp/Decimal; an integer cell meeting aDoublewidens toFloat; an all-null column answersString). MoonFrame takes a dependency on the moondb interface package only — no database backend of its own. The driver type inread_sql's signature is moondb's, so a caller brings their ownmoonbitstack/moondbdependency. -
write_sqlwrites a frame into a database table: the table is created from the frame's columns, each typed and spelled for the driver's dialect, andif_exists~says what meets a table already there —Failleaves it to the database's own error,Replacedrops the table first,Appendonly inserts. The rows go in by bound statement, at most 999 values a statement, inside one transaction where the dialect has one.read_sql_tablereads one table whole.scan_sqlis the lazy source over a query: the answer is read through the driver's cursor in batches, the projection naming the columns built, the first predicate filtering each batch, and a sunkheador forwardslicestopping the read at the window's end. A stream holds every batch to its first batch's dtypes, whereread_sqlwidens: a later cell of another shape refuses, naming the column.write_sql's andscan_sql's docstrings state the two contracts. -
Excel workbooks read and write over
moonbitlang/mbtexcel, the workbook library the entries ride — which moves the tree'smoonbitlang/asyncto the version that library names.read_exceltakes one sheet — the first, or the oneExcelReadOptionsnames, andexcel_sheetslists them — into a frame whose columns take the narrowest dtype holding every value. A number under a date format reads as aDateor aTimestamp, under a time format as the time of day, and under the formats a locale re-spells as the number it is; a cell carrying an error and a formula with no cached value read null.write_excelwrites a frame as one sheet: an integer, a float, and a boolean as the sheet keeps them, aDateand aTimestampas date serials under date formats, text as text whatever it spells, and aDuration, aDecimal, a list, and a struct as their text forms.read_excel's andwrite_excel's docstrings state the two contracts. -
read_excel,parse_excelandexcel_sheetsopen an OpenDocument spreadsheet (.ods) and an Excel 97–2003 workbook (.xls) as they open an Excel workbook — which a macro-enabled.xlsmis: the layout is the one the file's bytes name, and a sheet reads into the same frame by the same rules whichever it is. A column takes the narrowest dtype holding every value; in the two Excel layouts a number under a date format is aDateor aTimestamp, and a cell an OpenDocument spreadsheet types as a date is that date whateverdatesis. Both are read only:write_excelwrites an Excel workbook. No existing call changes. -
Avro files read and write over a codec inside the module (
internal/avro).read_avrotakes the file's record as the frame's columns, its blocks stored as encoded or compressed by deflate, snappy, or zstandard; a date, a timestamp, and a decimal ride the format's logical types, an enum reads as its symbol, and a list or a struct as theList/Structdtypes.write_avrowrites every field as a nullable union, in blocks of ten thousand rows, and the same frame writes the same file.parse_avro's docstring states the mapping and the refusals. -
Stata datasets read and write over a codec inside the module (
internal/stata): releases 113 to 119 read in either byte order, and 118 is written. A numeric cell outside its storage's valid range reads as missing, a variable under a date format as aDateor aTimestamp, and value labels are not applied.write_statawrites every column under its own name and refuses a name the format forbids; the same frame writes the same file. A round trip is not the identity: aBoolcolumn reads back asInt0 / 1, anIntcolumn with a cell past thelongstorage asFloat, a NaN as missing, a missing string cell as the empty string, and aNullcolumn as an all-missingFloatcolumn.parse_stata's docstring states the mapping and the refusals. -
XML documents read and write over an event reader (
Milky2018/xml) inread_xmlandwrite_xml. A path names the rows — from the document element, from its children, or at any depth below it — and a row's columns are its attributes, its own text, and its direct child elements; each column takes the narrowest dtype holding its values. A document declares its encoding, and UTF-8, UTF-16, and ISO-8859-1 read.write_xmllays a frame out in the same shape, a missing cell an empty element.parse_xml's andformat_xml's docstrings state the two contracts. -
HTML tables read through a tokenizer inside
ioinread_htmlandparse_html: everytablea frame, the rows read in athead— or the leading rows ofthcells — naming the columns, a cell's spans saying how far it reaches, a cell's text decoded and its whitespace runs folded, a missing-value spelling reading missing, and each column typed by the CSV reader's rule.parse_html's docstring states the contract. -
DataFrame::to_latexrenders a frame as a LaTeX table overLatexOptions: a booktabstabular, or alongtable, with an index column, an optional caption / label / placement, a column selection and a column specification, escaping on by default. A null renders asNaN.to_latex's docstring states the output. -
SAS files read, and the transport format writes, over codecs inside the module (
internal/xportfor the transport format,internal/sas7bdatfor the data set).read_sasreads a Version 5 transport file (XPORT) or a SAS data set (sas7bdat), whichever the file opens as. A numeric variable reads asFloat, a character variable asString, the 28 missing spellings as missing, and a variable under a date format as aDateor aTimestampwhile every present cell is a whole number of the unit.write_saswrites the transport format, every column under its own name — one to eight of ASCII letters, digits and_, opening on a letter or_— and refuses a name the format does not hold rather than changing it; the same frame writes the same file. A round trip is not the identity: anIntand aBoolcolumn read back asFloat, a NaN as missing, a missing string cell as the empty string.parse_sas's andwrite_sas's docstrings state the two contracts. -
SPSS system files read over a codec inside the module (
internal/spss); nothing is written.read_spssreads a.savfile or its zlib-compressed.zsavform, its cases plain or bytecode-compressed, in either byte order. A numeric variable reads asFloat, a string variable asString, the system-missing value and a declared missing value as missing, and a variable under a date, datetime or time format as aDateor aTimestampwhile every present cell is a whole number of the unit.parse_spss's docstring states the mapping and the refusals. -
ORC files read over a codec inside the module (
internal/orc); nothing is written.read_orcreads the format's versions 0.11 and 0.12 under none, zlib, snappy, LZ4 or zstandard compression; a boolean reads asBool, an integer asInt, a float asFloat, a string asString, a date asDate, a timestamp asTimestampin microseconds, a decimal asDecimal, and a list or a struct as theList/Structdtypes. A projection keeps only the top-level fields it names, and a field it leaves out is never decoded.parse_orc's docstring states the mapping and the refusals.scan_orcis the file's lazy source, as Polars'scan_orc: a stripe a batch, a sunk window skipping the stripes outside it. -
The Parquet reader inflates ZSTD-compressed pages, which it refused before by codec; a file written with Zstandard reads now, and the writer's codecs are the same three.
read_parquetandscan_parquetboth read such a file. -
Iceberg tables read over a metadata codec inside the module (
internal/iceberg) and the Parquet codec; nothing is written.read_icebergtakes a table's directory, finds its current metadata file, and reads the snapshot's every live data file in the plan's order, each column by the field id it carried when the file was written; a column an identity partition dropped from the data reads as the partition's value, and position deletes apply. An equality-delete file, afloatcolumn, a nested column, a file that names no field id and a format version past 3 refuse by name.read_iceberg's docstring states the rules and the refusals. -
Delta Lake tables read over a log codec inside the module (
internal/delta) and the Parquet codec; nothing is written.read_deltatakes a table's directory and, optionally, a version: the JSON commit files are read from version 0 on, once, into the snapshot's plan, and every live data file reads in the order the log added them — a column by the field id the name mapping gives it, else by its name, a partition column from the file's path record typed by the column's dtype, and a deletion vector's rows dropped. A reader feature not implemented, a column type not carried and a log that starts after version 0 refuse by name.read_delta's docstring states the rules and the refusals. -
HDF5 files read over a container codec inside the module (
internal/hdf5); nothing is written.hdf_keyslists the keys a file stores a table under, andread_hdfreads one — its columns in the frame's own order, its rows positional, the index columns the file stores beside them not read. A column reads as the dtype the table names it: an integer asInt, a float asFloatwith a NaN read null, a boolean asBool, text asString, a datetime asTimestampand a timedelta asDuration. The container's superblock, object headers, groups, datasets, attributes and deflate / shuffle / fletcher32 filter pipelines read; the fixed layout, a categorical, a multi-level index, a time zone, an encoding other than UTF-8, a filter other than those three, a dense link or attribute storage and an external link refuse by name.read_hdf's docstring states the rules and the refusals. -
Lance datasets read over a codec inside the module (
internal/lance); nothing is written and no catalog is involved — the path names the dataset's directory.read_lancereads the current snapshot: the manifest of the greatest version under_versions/, under either of the format's naming schemes, with the schema it names, every live data file in its fragment's order (file formats 2.1 and 2.2) and the rows a deletion file marks dropped. A column reads as the manifest's logical type: an integer asInt, a float asFloat, text and binary asStringwhen UTF-8, a date asDate, a timestamp asTimestamp, a duration asDurationin microseconds, a decimal asDecimal, and a list, fixed-size list, struct or map as theList/Structdtypes. Aprojectionkeeps the fields it names in the manifest's order. Data file formats 2.0 and 2.3, a time of day, intervals, unions, a packed struct, a blob, an encoding this reader does not carry, and a dataset feature flag that changes what the manifest means refuse by name.read_lance's docstring states the rules and the refusals. -
Fixed-width files join the facade:
read_fwf/parse_fwfoverFwfReadOptions— a layout inferred from the first lines or named bywidths/colspecs, a header underhas_header,namesin place of the header's,skiprows,infer_nrows— each line a row, a blank line skipped, each column typed by the CSV reader's rule. No existing call changes. -
A column can hold lists and structs.
Series::from_scalarsbuilds one from nested values and infers its dtype from the first cell that names one. A nested column is carried whole — through the row verbs, the comparisons,sort/rank/min/max(one total order: a list element by element, a struct field by field), andgroup_by/join/unique/n_unique(by content) — while arithmetic, the statistics, the logical and string verbs, and every cast refuse it. The dtype's docstring states which verbs read a nested column. -
read_json/read_ndjsonread a field of arrays or objects as a nested column, where 0.9 kept every such cell as its text: each position (the cells, a list's elements, a struct's fields) takes the narrowest dtype accepting every value in the inference window, andStringkeeps each value as its text where none does. Adtypespin toList/Structis read on these readers and reaches the elements and fields; the CSV reader refuses such a pin, andwrite_csvwrites a nested cell as its text. The rule is stated onparse_json_strand explained intype-inference.md. -
Arrow IPC reads and writes over a codec inside the module (
internal/ipc).read_ipctakes the file framing and the stream framing, the metadata versions through V5, either endianness, LZ4 and Zstandard buffers, dictionary batches (a delta batch among them), and lists and structs, which read as theList/Structdtypes.write_ipcwrites one schema message and one record batch, in the file framing unlessformat=IpcFormat::Streamnames the stream framing, and compresses each buffer undercompression=when the frame is the shorter spelling.scan_ipcis the lazy source over a payload — the projection names the columns that decode, and a sunkhead/tail/sliceskips the record batches outside its window without decoding them, so a refusal confined to a skipped batch does not surface — andsink_ipclands one record batch per batch, the schema and each decimal's window fixed by the first. The mapping from Arrow types to dtypes, and the types that refuse by name, are stated onread_ipc.
Source-level note:
- The
lazypackage no longer exists: the deferred query plan lives in the frame package beside the engine that executes it. A directimport "ihb2032/MoonFrame/lazy"must import…/frameinstead (or the facade, whose surface is unchanged —LazyFrame,Optimizations, and thescan_*sources re-export exactly as before; thescan_*functions now sit in the io package, beside the readers and drivers they defer, and reach callers through the same facade names). Nothing about the plan's behaviour changed. DataFrame::to_lazy()joinsLazyFrame::LazyFrame(df)as the entry to the deferred plan — the method spelling the shared package makes possible (lazyitself is a reserved word and cannot name a method). The constructor stays; existing calls compile unchanged.DataError::LengthMismatchcarries the disagreeing lengths:LengthMismatch(expected, got)— the length the verb needed (a frame's height, a schema's width, the one cell a group reduction owes) and the length it met. Amatcharm spelling the bare variant must add the pair (LengthMismatch(expected, got)orLengthMismatch(_, _)), and the message renders both ("Length mismatch: expected 3, got 4"where it used to say only "between columns").DataFrame::sample's first parameter is now optional:sample(n?, …)— a call that passednpositionally (sample(3, seed=7)) must spell it (sample(n=3, seed=7)), because the parameter now shares the slot with the newfraction?(exactly one of the two names the draw size, a fraction drawingmax(1, round(fraction × nrows))rows of a non-empty frame,(0, 1]enforced).format_vega_lite/write_vega_litetake aChart, not a bareChartSpec: a single view isChart::of(spec)—format_vega_lite(df, spec)becomesformat_vega_lite(df, Chart::of(spec))— and the compositions the mirror now carries are built with the@chart-qualified wrappers:Chart::Layer(VegaLayer::VegaLayer([Chart::of(…), …])),Chart::VConcat/HConcat/Concat(VegaConcat::VegaConcat(…)),Chart::Facet(VegaFacet::VegaFacet(child, row=VegaFacetChannel…)), andChart::Repeat(VegaRepeat::VegaRepeat(child, column=[…]))— every child shares the frame the call inlines once, and the facet channels resolve their columns against it ahead of the child.- The transform pipeline is mirrored: a chart (single view or
composition) carries
transform=[…]— all nineteen schema transforms (@chart.VegaAggregateTransform…@chart.VegaWindowTransform, built as@chart.VegaTransformvariants) with their field-def lists, sort keys, frames, and lookup sources — and the filter predicate union@chart.VegaPredicatecovers the expression string, the field comparisons (equal/lt/lte/gt/gte/range/oneOf/valid, each with an optionaltimeUnit), parameter references, and thenot/and/orcompositions. The Vega expression language stays aStringthroughout. - The theme surface is mirrored: a chart carries
config(the@chart.VegaConfigtree — the per-mark style defaults through one@chart.VegaMarkStyleunion, the scale / axis / legend / header / title defaults, the view frame, the named ranges and the style index, the composition grid, the selection defaults, the locale and format defaults, and the top-level scalars) andusermeta(a free-form JSON object the runtime passes through untouched). - The interactive surface is mirrored: a chart's
paramsarray declares@chart.VegaParams — a variable bound to an input widget (checkbox, radio / select, range slider, free text, or a direct element binding) or driven by an expression, and a selection driven by direct manipulation (a click-setpointor a drag-drawninterval, with the brush styling, projection fields / encodings, and per-facet resolution) — and an encoding channel carries acondition:@chart.VegaCondition::When(predicate, value)colors what the predicate selects. The v6 detail the corpus walker caught: the condition's predicate key istestand its arm is a constantvalue, not a field definition. - The chart export is a typed mirror of Vega-Lite v6 (the emitted
$schemapoints at the v6 URL, and CI walks a golden corpus of emitted specs against the vendored 6.5.0 schema), and the builders speak channels: everyChartSpecconstructor takesVegaChannelvalues (built withfield("name")— thecolidiom of the chart export — orconstant(...)/datum(...)for value / datum definitions) instead of bare column strings, andcolor_typeis gone — a type override is a channel modifier.ChartSpec::bar("region", "revenue", title="T")becomesChartSpec::bar(field("region"), field("revenue"), title="T"), andcolor="g", color_type=Nominalbecomescolor=field("g", type_override=Nominal). The mark family grew to seventeen (image/geoshape/errorbar/errorbandand more joined the original four), the channel set to thirty-eight (the error, offset, geo, fill / stroke, andtimechannels among them —ChartSpec::ofis the general constructor that carries them all), a channel may declare any of the schema's twenty-fiveaggregateoperations, explicitbinparameters (VegaBin::Params), atimeUnit(the schema's eighty-unit closure), and the fullsortunion, and the spec gained the top-level chrome (name,description,autosize,padding,background) withwidth/heightas aVegaExtent(Px(320)/Container/Step(24)), a parameterisedtitle(@chart.VegaTitle::Params— with subtitle, anchor, and font styling), a geographicprojection, and aviewbackground. The guide trees are mirrored too —@chart.VegaScale(with its domain / range / scheme / nice / bins unions),@chart.VegaAxis,@chart.VegaLegend, and@chart.VegaTitleParams, each carried by the channel or the spec it guides — and the deep mirror types (these, and the transforms / config / params stages still landing) are reached through@chartqualification rather than the facade. plot(df)is the frame-first entry into that chart export: the frame is bound once at the entry and the terminals render without re-passing it —plot(df).bar(x="region", y="revenue", title="Revenue by region").write_html("out.html"), withto_json()for the spec string and.encode(y=field("revenue", aggregate=Sum))to swap a plain column for a full channel definition. Each mark method is itsChartSpeccounterpart over column names, so the chain emits what the mirror emits; the data work (filter, aggregate) stays on the frame ahead ofplot, and.chart()/.spec()hand the underlying mirror values back for composition and the deep trees.- The chart mirror now refuses to emit keys its Vega-Lite host does not
carry, and the builders lost the parameters that could only produce
them. A facet channel (
@chart.VegaFacetChannel) no longer takesalign/center/spacing— those belong to the facet operator (VegaFacet::VegaFacet(…, spacing=…)) — and a by-channel sort on a facet channel (sort=ByChannel(..)) raisesDataError::InvalidOperationat emission, because the schema'sFacetFieldDef.sorthas no bare-channel form (sort by a field or an explicit order instead).VegaConfiglost itsformatparameter (the config host has no such key — the number / time / tooltip format defaults arenumber_format/time_format/tooltip_format), and itslegend/titleblocks take the config hosts' own narrowed types,@chart.VegaLegendConfig(a channel legend'sformat/format_type/label_expr/tick_min_step/type_/valuesdo not exist there) and@chart.VegaTitleConfig(a spec title'stext/subtitle/styledo not). The view frame'sdiscrete_height/discrete_widthtake@chart.VegaDiscreteSize(Px(n)/Step(n)) — the config host has no responsive"container"form for them. - More free strings and optional halves narrowed to the schema's own
enums and requireds: a mark style's
interpolate(and an errorband config's) is@chart.VegaMarkInterpolate(the schema's fifteen line / area methods),@chart.VegaInterpolateParamstakes a requiredtype_~ : @chart.VegaInterpolateParamType(rgb/cubehelix/cubehelix-long— the parameter form's own three), and a window field'sopis the union@chart.VegaWindowFieldOp—Aggregate(VegaAggregate)orWindowOnly(VegaWindowOnlyOp)— which is what makes the window-only functions (rank,row_number,lag, …) reachable at all;VegaWindowFieldalso carries the window functions' numericparam(alag/leadoffset, annth_valueindex). - Three emission rules changed what existing builders produce, not just
what they accept. A
Durationcolumn now types"quantitative"and itsdata.valuescells leave as microsecond counts (Vega's temporal has no ISO-duration parser). A nested child emits only the chrome its host carries —autosize/background/padding/config/usermetanever nest, and alayermember additionally dropswidth/height/view; a nested selection parameter drops itsviewskey (it exists only on the top-level parameter form). A constant on a position channel (x/y, the2/ polar forms) must be a number or the string"width"/"height"— anything else raisesInvalidOperation— and a secondary channel (x2, the error forms, …) drops aconditionthe way it already droppedsort/format/stack. Field references escape consistently now: a facet channel's field, a repeat's row / column lists, a predicate's comparison field, and every transform field reference (group-by keys, aggregate inputs, sort fields) escape dots / brackets the way encoding channels always have, so a column literally nameda.bresolves to itself everywhere; output names (as) and the expression inside acalculatestay as written.
What has landed on main:
- The
dt_*family reads aTimestampoperand: the calendar verbs (dt_year/dt_month/dt_day/dt_day_of_week, previouslyDate-only) take aDateorTimestampoperand — aTimestampreads its date half — and the new clock verbsdt_hour/dt_minute/dt_second/dt_microsecondareTimestamp-only (aDatenames no time of day). - The cast surface offers the temporal pair:
Date→Timestamp(each day count scaled to microseconds, exact orParseErroron the far end of theDaterange) andTimestamp→Date(the microsecond count floored to whole days). Every other rider cast keeps its refusal. - The readers'
dtypesoverride pins the rider dtypes:Date/Timestamp/DecimaljoinInt/Float/Bool/Stringas pinnable, parsing the writers' own text forms (ISO date, ISO timestamp with an optional trailingZand an optional one-to-six-digit fraction, the decimal value reader's every spelling — positional, scientific, and the exceptional literals). Inference still never produces a rider: a written-back rider column reads asString/Floatunless pinned. On the JSON / NDJSON side a rider pin readsStringvalues only — the riders' one carrier in a format with no native type for them; a JSONNumberunder aDecimalpin is a mismatch, never a coercion (a JSON string under aDecimalpin parses the engine's value reader — the writer's own spelling, positional and scientific alike). Expr::over(keys)— the window wrapper: an aggregating inner (.sum(),.mean(), …) broadcasts its group's single cell over the group's rows, a group-length inner (.rank(),.shift(n),.cum_sum(), …) lands cell-for-cell, and any other length raises. Key semantics mirrorgroup_by(expression keys, a null key its own group). Nesting a window in a window or using one inside anaggexpression refuses, and the optimizer fences windows whole: no predicate or projection crosses a stage that defines one.- The
ewm_mean/ewm_std/ewm_variancefamily — the exponentially-weighted recurrence (span~oralpha~,adjust~,min_samples~,ignore_nulls~; the deviation / variance are the biased estimator, and a raw-moment cancellation that would land below zero saturates at zero — a true variance is never negative). AlwaysFloat. - Two parameter envelopes and one buffer bound that used to abort now
refuse: the string pad verbs (
str_pad_start/str_pad_end/str_zfill) refuse a width past 16,777,216 characters per cell withInvalidOperation, and aSeries::gatherwhose repeated indices would amplify a String column past2^31 - 1payload bytes refuses the same way instead of wrapping the buffer'sInt32offsets. - The string layout's payload bound now refuses everywhere a build can
reach it, not only at the gather:
Series::from_strings(and the engine-seamfrom_string_options) raisesInvalidOperationwhen the cells' combined UTF-8 payload passes2^31 - 1bytes, where theInt32offset total used to wrap and abort inside the allocator. The refusal propagates honestly instead of being swallowed, so the verbs whose rebuild rides the same constructors are nowraiseing too —Series::sort/reverse/drop_nullsandDataFrame::reverse/shufflegainraise @types.DataErrorin their signatures (a call inside a raising function needs no change; a total caller addsraiseorcatch). The bound itself is unchanged and unreachable for any column the layout could already hold: a reversal gathers each cell once, so only a multi-gigabyte resident build or an amplifying gather ever meets the refusal. DataType::Duration/Scalar::Duration— the fourth I64 rider: a span of whole microseconds. The temporal arithmetic reads it:Timestamp − TimestampandDate − Dateproduce one,Timestamp ± DurationstaysTimestamp(checked — a shift off theInt64range refuses), andDate ± Durationpromotes toTimestamp. Ordering / grouping / joins compare the raw spans; whole-framemin/maxanswer (the registry's neworderablerow, which the frame-level gate now reads instead of its own variant list). It renders as an ISO 8601 days-and-time duration; the writers emit that text and no reader parses it (adtypespin refuses it).- Decimal
roundis the engine's own quantize: half-even to the target places, NaN and ±∞ passing through as values, an impossible target a NaN cell. The approximate unary verbs (floor/ceil) stay fenced. A negative target clamps to zero places, theFloatrounding's own rule. - Decimal division stays
Decimal:Decimal / Decimal(anIntlifting exactly) divides in the IEEE engine — 35 quotient digits, one rounding, ties to even, the exact quotient keeping the preferred exponent; 0/0 and ∞/∞ are NaN, a nonzero over a zero ±∞, an overflow ±∞ — values, never refusals. describecarries the linear-interpolated quartiles (25%/50%/75%, nulled for a non-numeric / empty / all-null column like the mean) — the summary's shape widens from 8 to 11 columns.LazyFrame::collect(optimizations~)— anOptimizationsrecord (re-exported on the facade, every field defaulting to on) gates each optimizer stage: the three pushdown passes and the two rewrite rules. Any subset collects the same frame; a stage off only removes rewrites.- The parquet columnar interchange returns — a native reader and
writer (
read_parquet/write_parquet/parse_parquet, the lazyscan_parquet) over a module-internal codec: thrift compact metadata, RLE definition levels, PLAIN and dictionary-decoded values, UNCOMPRESSED / SNAPPY / GZIP page bodies. The riders interchange by value (DATE,TIMESTAMP_MICROS,DECIMALoverINT64precision 18 or, past that window,FIXED_LEN_BYTE_ARRAY(16) precision 38); the one narrowing is a writtenDuration, which rides a bareINT64and reads backInt(no standard converted type names a microsecond span). AFLOATcolumn refuses on read rather than silently narrowing aDouble. ABoolcolumn rides the spec's own PLAIN packing (bit-packed LSB first, eight cells to a byte), so files written by other tools read back correctly; a V2 data page reads its level bytes raw and only its values through the codec, the spec's compression boundary. A string cell holding an unpaired UTF-16 surrogate refuses the write (InvalidOperation), the same guard the text writers carry. Hostile counts refuse with a locatedParseErrorinstead of sizing an allocation: a chunk naming more values than its bytes could carry, a page naming more than its chunk, an RLE run count or a SNAPPY declared length past their bounds. The projection is lenient like the text readers': a name the file does not carry builds no column (the file's rows over zero columns), and the expression that references the name raises theColumnNotFounda full read plus a select would — which is also what keeps the lazyscan_parquethonest when the optimizer absorbs a filter and narrows the projection in one pipeline: the predicate's own columns ride the decode even when the projection above drops them, the same key-column contract the text scans' pruner honours, so a filtered select or a filtered group-by collects to exactly its eager spelling. - The parquet codec reads and writes the spec's own level encodings. A
V1 data page prefixes its RLE definition-level run with the 4-byte
little-endian length the format defines (a file MoonFrame wrote
before this change carried the run bare — those files now refuse on
read instead of mis-decoding), and a V2 page decodes its levels as
the RLE / bit-packed hybrid stream the page header itself sizes — no
prefix, never compressed — where the reader once read a bare bitmap
no parquet writer emits, under the page type (3) a foreign V2 page
actually declares. The schema walk reads the repetition type
and child count too: a REQUIRED column's pages carry no level section
at all and their values begin at the body's first byte (a foreign
REQUIRED column was mis-refused before), a group element refuses
naming the group instead of pairing a chunk under the BOOLEAN the
absent physical type once defaulted to, and a REPEATED leaf refuses
the same way. A dictionary page no longer counts its entries into the
chunk's value total (a dictionary chunk with several data pages
reads now), a V2 page whose header spells
is_compressed=falsedecodes its values raw however the chunk's codec votes, a bare INT32 column reads as a signedInt, and the thrift skipper bounds its nesting so a footer spelled to recurse refuses with a locatedParseErrorinstead of exhausting the stack. - The parquet codec carries a conformance pass against the format's own
definitions. A dictionary page header now reads in the thrift
bindings' field order —
num_valuesbeforeencoding— where a foreign dictionary page whose entry count spells no legal encoding value was refused as unsupported. The footer walk checks the file's leadingPAR1magic alongside the trailing one, so a file is parquet from byte zero or refuses. Each rider's schema element carries theLogicalTypeannotation beside its converted type — the format's own rule that a writer spells both: the union variant the modern readers read (STRING,DATE,DECIMALwith its scale before its precision,TIMESTAMPwith the UTC-adjusted bool and theMICROSunit). The thrift skipper reads a byte field (wire type 3) as its single raw byte rather than a varint whose continuation bit would swallow the next field header. - A foreign
DECIMALcolumn's annotation now carries the format's own envelope on read: the precision is required, one to nine digits overINT32, one to eighteen overINT64, up to the payload's capacity overFIXED_LEN_BYTE_ARRAY, and at most 38 over the legacy variable-widthBYTE_ARRAY, with the scale never past the precision — a file declaring past that envelope refuses the column instead of reading cells under an annotation the payload cannot honour. The writer declares precision eighteen overINT64and thirty-eight over the wide payload. - The chart export gains a browser page:
format_vega_html/write_vega_htmlwrap the specificationformat_vega_liteemits in a standalone HTML document that loads the Vega runtime from three pinned CDN scripts (vega@6.4.0 / vega-lite@6.5.0 / vega-embed@7.3.0) and hands the embedded spec tovegaEmbed— opening the file renders the interactive chart, with vega-embed's action links for SVG / PNG export. The channel contract is the spec emitter's (ColumnNotFoundfor a column absent from the frame), and the embedded JSON rewrites every literal<to its\u003cescape (the U+2028 / U+2029 line separators likewise), so chart data cannot close the host<script>element early. - A signed year zero refuses:
-0000-01-01(and the timestamp spellings built on it) read as year 0, but the writer emits year 0 only as the unsigned0000-01-01— the form the parsers promise to accept — and ISO 8601 agrees a signed zero is no year. The signed form now refuses like every other shape the writers do not emit; the unsigned one is unchanged. - A year past the ISO 8601 basic range renders in the expanded form's
own sign: a
DateorTimestampin year 10000 or beyond now renders+10000-…where it rendered the bare digits before (the negative side always carried its-; an expanded year without its sign is no ISO spelling). The parser reads the signed spelling back — and still reads the bare digits too, the spelling earlier writers emitted — while a+on a four-digit year and a signed year zero (+0000-…, like-0000-…) refuse as shapes no writer spells. Decimalbecomes an IEEE 754-2019 decimal128 floating-point dtype — the fixed-pointDecimal(scale)over an unscaledInt64retires. Source-breaking: the variant loses its parameter (DataType::Decimal— amatcharm spellingDecimal(scale)or a constructionDecimal(2)fails to compile) and the scalar carries the engine'sDec128value (Scalar::Decimal(Dec128)— the two-argument spelling is gone). The engine (Dec128, re-exported on the facade besideDataType/Scalar) is a sign, up to 34 significant digits, a per-value quantum exponent in[-6176, 6144], and the exceptional shapes ±infinity / NaN / signed zero as values: every operation computes exactly and rounds once (ties to even), an overflow is ±∞, a lost magnitude a signed zero — the fixed-point era'sInvalidOperationrefusal family (the envelope check, the checked multiplies, the rescale lifts, the sum past 18 digits, the negation / round overflows) is gone with the scale it was about. Construct decimals withDec128::of_int64/Dec128::of_int64_scale/Dec128::parse_opt/ thenan/infinity/zeroconstructors, and build a decimal column withSeries::from_scalars(name, cells, dtype=DataType::Decimal)overScalar::Decimalcells (the expression layer'slitdoes the same).- The decimal arithmetic semantics follow the engine:
+/-/*//all stayDecimal(Intlifts exactly; aFloatoperand promotes the pair toFloatthrough the correctly-rounded conversion — the fence the fixed-point era kept between the exact and approximate dtypes is a promotion now). Exact results keep the cohort's preferred exponent (1.50 + 0is1.50);sumpropagates NaN and folds +∞ with −∞ into NaN while an overflowing total is ±∞;min/maxskip NaN; sorting reads the total order (NaN past everything, −0 and +0 equal — theFloatstack's own shape); comparisons, grouping, joins, andn_uniqueread numeric value equality, cohorts comparing equal (1.0joins1.00). - The decimal value fence is deleted with the refusals it guarded: the
optimizer's decimal risk family, its wbtests, and the
may_carry_decimalprobe the file sources carried are gone, so a predicate over decimal arithmetic sinks exactly like one overInt(the temporal family keeps its fence — the microsecond domain still refuses on values).check_decimal_scaleandparse_decimal_unscaled_optretire from the engine seams. - The casts cross both ways:
Int→Decimalexactly,Float→Decimalthe correctly-rounded conversion,String→Decimalthe value reader,Decimal→Inttruncating toward zero (the exceptionals and out-of-range magnitudes refusing like theFloatsource),Decimal→Floatthe correctly-rounded conversion,Decimal→Stringthe value rendering. The parquet interchange chooses the payload per column at the one adaptive scale every cell honours:INT64+DECIMAL(precision 18) while the scale is at most eighteen and every lifted magnitude fits eighteen digits, and otherwise the format's wide decimal —FIXED_LEN_BYTE_ARRAY(16) +DECIMAL(precision 38, big-endian two's complement). A NaN / ±∞ cell always refuses (the fixed-point interchange has no exceptional spelling), as does a column past the 16-byte payload's own window (a scale past 38, or a lifted magnitude past 38 digits). Reading takes the annotation at the format's word: aFIXED_LEN_BYTE_ARRAYof any width from one to sixteen bytes strides and decodes exactly while the precision stays inside the format's capacity rule (floor(log10(2^(8n−1) − 1))digits),INT32+DECIMALcovers the small-value payload, and the legacy variable-widthBYTE_ARRAY+DECIMALtrims its redundant sign-extension bytes. A foreign payload carrying more than the dtype's 34 significant digits rounds once into the engine.
No source-level migration steps. v0.8.1 is an additive patch: every v0.8.0
symbol and signature is unchanged, and nothing is renamed, removed,
re-signed, or given a new required match arm. What the patch adds: the
always-Float math family on Expr (sqrt / cbrt / exp / ln /
log2 / log10, the trigonometric and hyperbolic pairs, and the binary
atan2 / hypot, each taking any numeric operand and producing a
Float column); DataFrame::shuffle plus sample re-seeded on the
chacha8 generator — both remain deterministic in their seed, but the
concrete rows a given seed selects differ from v0.8.0's; the readers'
dtype override (dtypes~ on CsvReadOptions / JsonReadOptions, with a
dtypes() accessor) and the lazy scan_json, the JSON counterpart of
scan_csv / scan_ndjson; and transparent gzip on the io paths — a
.gz-suffixed write compresses, and a read whose leading bytes carry the
gzip magic decompresses on the fly. Riding along: the decimal value fence
covers a right join's clashing left column and clip, blank JSON input
asserts its dtype pins the way the empty array does, and the kernel /
optimizer hot paths dropped their per-walk allocations.
The operator-alignment sprint widens the join vocabulary and the dtype
set: three public enums each gain variants — JoinType the two joins,
DataType / Scalar the two I64-rider dtypes — under the repo's standing
exception that an enum may add
variants within a breaking release. Everything else the sprint adds is
additive — new verbs (pivot / unpivot, the positional / rolling /
cumulative families, the dt_* quartet, the null toolbox, the
distinctness predicates is_duplicated / is_unique / unique_counts,
mode / sample / the top_k family, rank / quantile on every
spelling, the dispersion reductions median / std / variance, the
named-aggregation verbs on GroupedDataFrame / LazyGroupBy, the
iter / iter2 / iter_rows iteration family, and
DataType::is_summable), new enums (PivotAgg, RankMethod,
QuantileInterpolation), and error-facing tightenings that turn silent
output into a raise on inputs no caller could have relied on. One
withdrawal rides along, forced by the toolchain rather than the sprint —
the Parquet interchange below.
read_parquet / write_parquet (with the string-level format_parquet /
parse_parquet and the lazy scan_parquet) are gone. The interchange rode
the mizchi/parquet reader/writer, whose dependency chain
(mizchi/duckdb) still ships the module-manifest format the current
MoonBit toolchain no longer parses — the package cannot be installed at
all, so the feature cannot ship with it. The wire format returns when the
upstream package publishes a toolchain-compatible release. Until then,
move Parquet data through CSV — the interchange landed and was withdrawn
on unreleased main only, so no released MoonFrame carries it and there
is no older version to pair an older toolchain with.
JoinType::Semi and JoinType::Anti — the existence filters, Polars'
how="semi" / how="anti" — join the enum, which makes an exhaustive
match over it fail to compile until the two variants are handled. Add the
arms (a Semi / Anti join keeps the left schema and filters rows by
whether a key match exists in the right frame); a match that ends in a
_ arm needs no change.
n_unique aligns with Polars: a null cell is one distinct value, so a
column with nulls counts one more than it used to, and an all-null column
now returns 1 (was 0); an empty column is still 0. Every spelling
moves together — Series::n_unique, Expr::n_unique, the whole-frame and
grouped verbs, and describe's n_unique row. count still counts
non-null cells, so the old reading's inputs remain reachable through
count and null_count.
vstack aligns with Polars: the stacked frame's schema must agree with
self's column-for-column — same count, same name in each slot, same
dtype — where it used to check only count and dtype, silently stacking a
renamed or reordered column's values under another name. Rename or reorder
other's columns (select) before stacking when the sources genuinely
differ.
clip aligns with Polars' post-1.0 reading: a null bound cell is no bound
on that side, so a present operand cell passes through where the old
nested-when lowering nulled it. A null operand cell still stays null,
and both bounds null keep the column unchanged. clip and diff also
moved onto dedicated AST nodes — a chained clamp or difference now renders
and evaluates linearly where the lowering embedded the operand 4 (resp. 2)
times per link — with no spelling change at the call site.
how=Right aligns with Polars' swapped-left-join reading: the right
frame's columns lead in right order (the coalesced key among them, its
values from the right), the left frame's non-key columns follow in left
order, and a left column clashing with a right name takes the suffix
(where it used to be the right one suffixed, the left columns leading).
Downstream code that indexed a right join's output by position, or that
read the suffixed spelling, moves with it.
A word-final Σ lowercases to ς (a medial one to σ), by the cased /
case-ignorable characters around it — the one contextual rule the default
conversion carries, matching Polars and Rust's str::to_lowercase; the
locale rules (Turkish dotless i) stay unapplied. The mapping tables
themselves were always generated from UCD 18.0.0 data, but the file
header claimed 16.0.0 (a hand-edit at the original commit, three
editions' worth of newer mappings ago); the regenerated header names the
edition the tables came from, and now also carries the Cased /
Case_Ignorable ranges Final_Sigma reads.
The JSON family grows the CSV reader's non-finite gate: with
allow_nonfinite_floats=false a number that overflows Double (e.g.
1e999) is not Float evidence, so the column stays String instead of
being silently retyped to Float(∞). The default is unchanged. And
reject_duplicate_keys now rides the parser itself instead of a
pre-parse scan: the error names the key's line and column (the scan named
the 1-based object number), and whichever trouble the parser meets first
— a repeat or a syntax error — is the one reported.
DataType::Timestamp and Scalar::Timestamp(micros) — microseconds since
the Unix epoch, UTC — and DataType::Decimal(scale) /
Scalar::Decimal(scale, unscaled) — a fixed-point decimal whose value is
unscaled × 10⁻ˢᶜᵃˡᵉ over an Int64 — are new, which makes an exhaustive
match over either enum fail to compile until the variants are handled.
Both ride the same 64-bit buffer an Int column always held, so nothing
about column storage changes; what each means is documented on the enum.
The decimal envelope — scale in [0, 18] — is enforced where a decimal
dtype is built (InvalidOperation outside it), + / - / * are exact
across scales and refuse (never wrap) when a magnitude or a product's
scale leaves the range, and sum keeps the dtype under the same refusal.
The readers never infer either dtype: a written-back Timestamp /
Decimal column reads as String / Float respectively. A match that
handles every variant except by a catch-all _ arm needs no change.
v0.7 is a pre-1.0 breaking release — the surface-focus one: io returns to
tabular interchange and the root facade narrows its first-contact face. Those
breaks are qualification moves. The widening break is the Date dtype: two
public enums gained a variant. The narrow one is on the error side: the two
error-detail enums became #non_exhaustive. Nine value-type members were
removed — predicates and comparisons that spelled out what a pattern match,
a column expression, or the comparison kernel already says — and two enums
are deleted outright: the sort vocabulary became Polars' two flags. The
nullable series constructors likewise converged into one, the window
verbs took Polars' saturating semantics — slice never raises, and a
negative head / tail count drops from the opposite end — and floats
now order by IEEE-754: NaN is a value in sort and propagates through
median. String case mapping and the default trim set went Unicode, and
the standards review closed two smaller gaps: Date renders ISO-8601
years zero-padded, and the CSV writer gained Polars' line_terminator
knob. The column selectors became DataFrame methods — the frame appears
once at the call site instead of twice.
DataType::Date and Scalar::Date(days) (whole days since the Unix epoch)
are new, which makes an exhaustive match over either enum fail to compile
until it handles the variant. Add a Date arm — what the variant means is
documented on the enum, and a column of it rides the same 64-bit buffer an
Int column always held, so nothing about column storage changes. A
match that handles every variant except by a catch-all _ arm needs no
change.
TypeMismatchDetail and ParseErrorDetail are now #non_exhaustive, so an
exhaustive match over either fails to compile until it ends in a ..
catch-all (a plain _ arm still compiles but warns — the .. spelling is
the blessed one). Add the arm and treat an unknown shape as you would an
unknown diagnostic today:
fn describe(detail : @moonframe.TypeMismatchDetail) -> String {
match detail {
Message(m) => "type mismatch: \{m}"
Expected(expected, got, _) => "expected \{expected}, got \{got}"
Operation(op, left, right) => "cannot \{op} \{left} and \{right}"
@moonframe.TypeMismatchDetail::.. => "type mismatch"
}
}From v0.7.0 on, a new diagnostic shape added to either enum is not a
breaking change: this arm absorbs it. DataError itself is unchanged — a
new error kind remains a deliberate, breaking change.
DataType loses the four single-variant predicates is_bool / is_float /
is_integer / is_string, and Scalar loses the five raising comparisons
eq / lt / gt / lte / gte. What stays is the part that carries
semantics a caller cannot spell another way: is_numeric reads the dtype
registry (a Date rides the Int buffer yet is not numeric), and the
as_* accessors are the typed reads behind every item() / get(). A
single-variant check is what a pattern match says in MoonBit, and a cell
comparison is a column-level concern — the expression verbs
col("a").eq(...) / .lt(...) / .gt(...), whose dtype matrix (including
the exact, promotion-free Int ↔ Float comparison) has its one home on
the comparison kernel:
// before
if field.dtype().is_integer() { ... }
assert_eq(Scalar::Int(2).gte(Scalar::Int(2)), true)
// after
if field.dtype() is Int { ... }
// compare cells through the column: an expression over the frame
let flagged = df.filter(col("q").gte(lit_int(2)))The six column-selector free functions — numeric_cols, cols_of_dtype,
cols_matching, cols_starts_with, cols_ends_with, cols_contains —
are methods of DataFrame now, so the free-function spellings (and their
root-facade re-exports) are gone. Each reads the frame it is called on;
the df argument the free function took at the front is the receiver:
// before
df.select(numeric_cols(df))
// after
df.select(df.numeric_cols())Sort direction and null placement leave the enum vocabulary — they are
Polars' descending / nulls_last flags now. DataFrame::sort /
LazyFrame::sort take (key, descending, nulls_last) tuples, and
Series::sort takes labeled descending? (default false) /
nulls_last? (default false; the default moved before the release — see
"Series::sort places nulls first by default" below). The mapping is
mechanical:
| before | after |
|---|---|
SortOrder::Asc |
false |
SortOrder::Desc |
true |
NullOrder::NullsFirst |
false |
NullOrder::NullsLast |
true |
// before
df.sort([(col("quantity"), SortOrder::Desc, NullOrder::NullsLast)])
s.sort(order=Desc, nulls=NullsFirst)
// after
df.sort([(col("quantity"), true, true)]) // (key, descending, nulls_last)
s.sort(descending=true, nulls_last=false)An explain rendering does not change: a plan still reads
SORT [col(qty) Desc NullsLast].
Polars' line_terminator knob arrives additively — default "\n"
unchanged, "\r\n" for RFC 4180's letter — and the reader takes every
CR/LF combination ("\r", "\n\n", …) back without a knob. The one
signature change: the constructor now raises InvalidOperation on a
terminator it cannot round-trip — an empty one (it would fuse every row
into one) or one holding any character other than \n / \r (the reader
breaks lines on those alone, so anything else fuses rows or glues itself
onto the last cell). So a CsvWriteOptions::CsvWriteOptions(...) call in
a non-raising context needs the usual catch / propagation.
Every read_* entry point decodes strictly: a file whose bytes are not
well-formed UTF-8 used to reach the parsers through a lenient decoder,
which merged a stray byte with the ones after it — swallowing a delimiter
or a quote and shifting every cell boundary that followed — or silently
dropped the rest of the file, so a Latin-1 or otherwise non-UTF-8 file
produced confidently wrong data with no error. It now raises
DataError::ParseError naming the first malformed byte's offset. Files
that are valid UTF-8 (a leading BOM included) read exactly as before.
A Scalar::Date whose year is under 1000 used to render without its ISO
padding — year 800 as 800-…, year 0 as 0-… — where ISO 8601's YYYY
basic range is 0000–9999. It now renders 0800-… and 0000-01-01,
a negative year carries its sign over a padded magnitude (-0002-09-16),
and a year beyond 9999 keeps its expanded spelling (-194022-09-24).
Dates in 1000–9999 — every date a reader or the epoch neighbourhood
produces — render exactly as before.
The two bespoke "NaN behaves like missing" rules are gone, replaced by the
IEEE-754 total order and Polars' own behaviour. In sort, a Float NaN no
longer follows the key's nulls_last flag like a null — it orders as the
largest value, trailing an ascending sort and leading a descending one,
independent of where the nulls sit. In median, a NaN no longer drops out
of the window — it propagates, as sum / mean always have; the median of
[1, 2, NaN] is now NaN (was 1.5), and the median of an all-NaN
column is NaN (was an empty-window InvalidOperation on the whole-column
path). min / max keep skipping it, null placement keeps its
direction-independent model, and only null is missing.
str_to_uppercase / str_to_lowercase map every cased letter through the
Unicode default case conversion — the simple one-to-one mappings (é
→ É, Greek and Cyrillic across their alphabets) plus the SpecialCasing
expansions — where they were ASCII-only before. A cell's length can grow:
straße uppercases to STRASSE (ß → SS), the fi ligature to FI,
and İ lowercases to i + combining dot above. The locale-conditional
rules (Turkish dotless i, final sigma) are not applied — the default
conversion carries no locale. The default str_strip_chars set widens from
ASCII whitespace to the Unicode White_Space property — NBSP, the narrow
no-break space, and the ideographic space now trim alongside tab, newline,
carriage-return, and space. A custom chars set is unchanged.
DataFrame::slice / Series::slice / LazyFrame::slice change both shape
and temperament: they take Polars' slice(offset, length) — a negative
offset counts from the end, an omitted length runs to the end, a given
one saturates at what remains, and a negative one is empty — and they never
raise, where the old half-open [start, end) form raised
IndexOutOfBounds / InvalidOperation on a window it would not honour:
// before
df.slice(1, 3) // rows [1, 3), raising on bad bounds
// after
df.slice(1, length=2) // the same two rows
df.slice(-2) // the last two rows (new: negative offset)
df.slice(1) // row 1 to the end (new: omitted length)An explain node renders the new shape: SLICE [1: 2], and SLICE [-2: ]
when the length is omitted.
DataFrame::head / tail (and the Series twins, and limit) follow
Polars' convention where they used to clamp a negative n to an empty
frame: head(-2) keeps every row but the last two, tail(-2) every row
but the first two, and a |n| past the frame's height leaves nothing.
df.head(-1) was 0×N; it is now (N-1)×N.
The default for nulls_last moves from true to false — Polars' own
default, which places missing cells at the head of an ascending sort. An
omitted flag used to read sort(nulls_last=true); it now reads
sort(nulls_last=false). DataFrame::sort / LazyFrame::sort keys spell
both flags explicitly and are unchanged, as is the rule that missing
placement does not flip with descending.
Series::from_int_options / from_float_options / from_bool_options /
from_string_options leave the public surface — the engine still builds
nullable columns through them, but a caller constructs one through the new
Series::from_scalars, Polars' pl.Series(name, [1, None]) translated to a
statically-typed language: the cells carry their own nullness as Scalar, and
the dtype is inferred from the first non-null cell or locked with dtype~:
// before
Series::from_int_options("score", [Some(1), None, Some(3)])
// after
Series::from_scalars("score", [
Scalar::Int(1),
Scalar::Null,
Scalar::Int(3),
])Every non-null cell must carry the target dtype exactly — an Int cell in a
Float column is a cast, not a construction, so it raises
TypeMismatch. An all-null column needs dtype~ (nothing can be inferred,
InvalidOperation), and dtype~ = Null names no physical column
(Unsupported). The null-free from_ints / from_floats / from_bools /
from_strings stay as they were. from_scalars is also the first public way
to build a Date column: from_scalars("d", [Scalar::Date(5L), Scalar::Null]).
Chart export (Vega-Lite) moved from io to the new chart package, along
with ChartKind / VegaType / format_vega_lite / write_vega_lite. The
root facade re-exports them from the new home, so @moonframe.ChartSpec and
the unqualified facade spellings keep working; only code that names the chart
types through @io moves:
// before
let spec : @io.ChartSpec = @io.ChartSpec::bar("region", "revenue")
@io.write_vega_lite("chart.vl.json", df, spec)
// after
let spec : @chart.ChartSpec = @chart.ChartSpec::bar("region", "revenue")
@chart.write_vega_lite("chart.vl.json", df, spec)parse_csv_str / parse_json_str / parse_ndjson_str and format_csv /
format_json / format_ndjson are still public in io — same signatures —
but the root facade no longer re-exports them. Import the io package and
qualify:
// before (through the facade)
let df = parse_csv_str("a,b\n1,2\n")
// after
let df = @io.parse_csv_str("a,b\n1,2\n")The file-level verbs (read_csv / read_json / read_ndjson /
write_csv / write_json / write_ndjson), the three option types, and
OnParseError stay on the facade.
v0.6 is a pre-1.0 breaking release — the API-convergence one. Where two spellings existed for building or configuring the same value, v0.6 keeps a single entry point; there are no deprecated aliases.
Field.nullable = false used to be reset by any op that re-derived a schema,
so a projection could quietly widen a caller's declared constraint. It is now
carried by every op that only moves a column, and re-derived only by ops that
compute cells. Nothing needs rewriting to compile; what changes is the schema
of the result — and, through the derived Eq, frame equality.
expression (over a from_rows frame declaring id non-nullable) |
v0.5 | v0.6 |
|---|---|---|
df.select([col("id")]).schema().field("id").nullable() |
true |
false |
df.drop([col("other")]).schema().field("id").nullable() |
true |
false |
df.with_columns([lit_int(0).with_alias("n")]) … id |
true |
false |
df.with_row_index() … id |
true |
false |
df.select([(col("id") + lit_int(1)).with_alias("id")]) … id |
true |
true |
If you were relying on a projection to widen a declared field — using
select to hand a non-nullable column to code that expects a nullable one —
state it explicitly: rebuild through DataFrame::from_rows with the schema you
want, or DataFrame::DataFrame(df.column_series()), whose derived schema
declares everything nullable.
Projecting a frame to zero columns used to return 0×0, discarding the height.
It now returns N×0. Nothing needs rewriting to compile — but code that
asserted the old shape, or that treated "no columns" as "no rows", changes:
| expression | v0.5 | v0.6 |
|---|---|---|
df.select([]).shape() (df 3-row) |
(0, 0) |
(3, 0) |
df.drop(every_column).shape() |
(0, 0) |
(3, 0) |
from_rows(Schema::Schema([]), [[], []]).shape() |
(0, 0) |
(2, 0) |
parse_json_str("[{},{}]").shape() |
(0, 0) |
(2, 0) |
df.select([]).is_empty() |
true |
false |
DataFrame::DataFrame([]) is unchanged at 0×0 — it infers its height from
the columns it is given. If you relied on a zero-column result reporting
is_empty(), test ncols() == 0 instead. check_invariants()' INV7 changed
with it: from "a column-less frame is row-less" to nrows >= 0.
| v0.5 | v0.6 |
|---|---|
Field::new("age", Int) |
Field::Field("age", Int) |
Field::with_nullable("id", Int, false) |
Field::Field("id", Int, nullable=false) |
f.name / f.dtype / f.nullable |
f.name() / f.dtype() / f.nullable() |
struct Field is opaque: a record literal ({ name: "age", dtype: Int, nullable: true }) outside types no longer compiles — build through
Field::Field(...) — and the three fields are priv, read through the
accessors of the same names. Reading a field was the smaller half of what
public fields allowed; the larger half was destructuring one, and since a
struct pattern must name every field or carry .., that would have made any
field this type gains later a breaking change. The options records
(CsvReadOptions, CsvWriteOptions, JsonReadOptions, HtmlOptions,
JoinOptions, ChartSpec) keep their readable fields — inspecting them is
their read API — at that same documented cost. The exceptions are the fields
holding a mutable array, CsvReadOptions.null_values and JoinOptions' three
key lists: reading one of those would hand back the array itself, so each is
private behind a copying accessor (null_values(), on_keys() /
left_keys() / right_keys()).
| v0.5 | v0.6 |
|---|---|
CsvReadOptions::default() |
CsvReadOptions::CsvReadOptions() |
{ has_header: true, delimiter: ';', infer_schema_rows: 100, null_values: [""], strict_column_count: false, on_parse_error: Raise, allow_nonfinite_floats: true } |
CsvReadOptions::CsvReadOptions(delimiter=';') |
CsvWriteOptions::default() |
CsvWriteOptions::CsvWriteOptions() |
JsonReadOptions::default() |
JsonReadOptions::JsonReadOptions() |
NdjsonReadOptions::default() |
JsonReadOptions::JsonReadOptions() |
parse_csv_str(text, options, strict_quotes=true) |
parse_csv_str(text, options=CsvReadOptions::CsvReadOptions(strict_quotes=true)) |
format_csv(df, options, sanitize_formulas=true) |
format_csv(df, options=CsvWriteOptions::CsvWriteOptions(sanitize_formulas=true)) |
options.null_values |
options.null_values() |
CsvReadOptions, CsvWriteOptions, and JsonReadOptions are pub rather than
pub(all), so a record literal no longer compiles outside io; every field has
a constructor parameter with the previous default, and only what differs needs
naming. Their fields stay readable — with one exception, null_values below —
which is the point of an options record, and also why a field added later is
not additive: a public field can be destructured, and a struct pattern must
name every field or carry ... Field additions to these types ride the minor
version, like a new pub(all) enum variant.
NdjsonReadOptions is removed: what took it in v0.5 — the NDJSON reader and
the then-current scan_ndjson_with_options — takes JsonReadOptions, which has
the same two fields. (Those *_with_options names are themselves v0.5 spellings;
the same release folded them into the plain entry points, so the v0.6 call is
scan_ndjson(path, options=…). See the table below.)
The strict_quotes and sanitize_formulas parameters are gone from the v0.5
parse_csv_str / read_csv_with_options / read_csv_projected and
format_csv / write_csv_with_options; set them on the options instead. The
lazy scan picks up strict quote validation this way, which the parameter form
could not express.
CsvReadOptions.null_values is now private, read through null_values(), which
returns a copy — as does the constructor, so mutating either array cannot change
what a reader (or a captured scan_csv plan) treats as null.
scan_csv / scan_ndjson now push a predicate into the read. Nothing about
values or dtypes changes — inference still walks the whole file — but a
ParseError in a row the predicate drops, in a column the predicate does not
read, is no longer raised, because those cells are never parsed. This is the
same trade projection push-down has always made for dropped columns. Code
that relied on a lazy pipeline failing on a malformed row it filters away
should read eagerly (read_csv(path).filter(...)) instead.
| v0.5 | v0.6 |
|---|---|
parse_json_records_str(text) |
parse_json_str(text) |
format_json_records(df) |
format_json(df) |
write_json_records(path, df) |
write_json(path, df) |
read_json already dropped the qualifier, so the records shape now has the
same four-verb spelling as CSV and NDJSON — read / write / parse_*_str /
format — and the wire shape ([{...}, ...]) is documented on the functions
rather than in their names.
They now live beside DataType / Scalar, because Series::sort (new in
v0.6) names them and series sits below frame. Through the facade nothing
changes — SortOrder::Desc still resolves — but a direct package import needs
the new home:
| v0.5 | v0.6 |
|---|---|
@frame.SortOrder::Desc |
@types.SortOrder::Desc |
@frame.NullOrder::NullsLast |
@types.NullOrder::NullsLast |
In v0.5 both variants held a flat String. They now hold typed detail enums —
TypeMismatchDetail and ParseErrorDetail — so a handler can branch on the
failure instead of parsing a message. The rendered text
(DataError::message()) is unchanged, so a catch that only formats the error
needs no change; a match that bound the string does:
| v0.5 | v0.6 |
|---|---|
TypeMismatch(msg) — msg : String |
TypeMismatch(detail) — detail : TypeMismatchDetail |
ParseError(msg) — msg : String |
ParseError(detail) — detail : ParseErrorDetail |
e.message() |
e.message() (unchanged) |
The expression tree is no longer a matchable pub enum Expr. It is an opaque
handle whose AST (ExprNode and the BinOp / UnOp / AggOp / StrOp tags)
lives in the module-internal internal/ir package. Building expressions is
unchanged; code that matched an Expr's variants from outside MoonFrame
must instead render it with Expr::to_string (the AST was never an intended
consumption surface):
| v0.5 | v0.6 |
|---|---|
match expr { @expr.Col(name) => … } |
expr.to_string() (no variant match) |
ClosedInterval (the is_between closed? argument) is new in v0.6 and lives
in types, beside the AST that carries it — @moonframe.ClosedInterval through
the facade, @types.ClosedInterval through a direct sub-package import. There
is nothing to move: v0.5 had no such type.
Expression equality compared the internal tree, which made how an operator
lowers observable: a release that normalised a tree or merged two node kinds
would have changed what compared equal, without changing what any expression
means. The impl is removed rather than promised. JoinOptions holds
expressions as its key lists, so its derived equality goes too.
Compare renderings, which is what explain() prints and what stays stable:
| v0.5 | v0.6 |
|---|---|
assert_eq(built, col("a") + lit_int(1)) |
assert_eq(built.to_string(), (col("a") + lit_int(1)).to_string()) |
opts_a == opts_b |
compare how / suffix / coalesce and the rendered on_keys() / left_keys() / right_keys() |
Rendering does not distinguish what it does not print: a lit_series shows as
its name and length, so two literal series over different cells render alike.
DataFrame::unique gained Polars' subset — the columns whose values form the
duplicate key — which makes it raise DataError (ColumnNotFound) instead of
total. Existing calls keep their behaviour but now need a raise context (or a
catch), exactly like filter / select beside them:
| v0.5 | v0.6 |
|---|---|
let out = df.unique() (total) |
let out = df.unique() (raises) |
| — | df.unique(subset=[col("id")], keep=Last) |
LazyFrame::unique takes the same subset? and stays total at build time; an
unknown name surfaces at collect.
| v0.5 | v0.6 |
|---|---|
df.take(indices) |
df.gather(indices) |
Series::gather is unchanged; DataFrame::take took the same name as in
Polars.
Regex string matching is new in v0.6 and arrives as a literal? : Bool argument
on the existing methods (expr.str_contains(pat, literal=false)), not as a
separate *_regex name. The default stays true, so every v0.5 call is
unaffected and renders in explain exactly as before.
Expr::children / referenced_columns / output_name are now #internal
(engine seams). LazyFrame::unique accepts keep? like the eager verb — a
pure addition.
| v0.5 | v0.6 |
|---|---|
DataFrame::new(columns) |
DataFrame::DataFrame(columns) |
Schema::new(fields) |
Schema::Schema(fields) |
lazy_frame(df) |
LazyFrame::LazyFrame(df) |
Construction is one spelling everywhere: Type::Type(...). These three renames
put the data types on it, and the constructors listed in the sections above
(Field::Field, CsvReadOptions::CsvReadOptions, HtmlOptions::HtmlOptions,
…) are written the same way — no constructor is exposed as a free function, so
the lazy_frame the facade re-exported is gone with them. The spelling reads
the same through the facade (@moonframe.DataFrame::DataFrame(...)) as through
a direct package import (@frame.DataFrame::DataFrame(...)).
A type whose construction genuinely has several shapes keeps a named
constructor per shape, so DataFrame::empty, DataFrame::from_rows, the eight
Series::from_*, JoinOptions::on / left_on / cross, and
ChartSpec::bar / line / point / area are unchanged.
| v0.5 | v0.6 |
|---|---|
Expr::col("a") |
col("a") |
Expr::lit(scalar) |
lit(scalar) |
expr.explain() |
expr.to_string() |
LazyFrame::from(df) |
LazyFrame::LazyFrame(df) |
Series::new(name, storage) / Series::from_builtin(name, column) |
Series::from_ints / from_floats / from_strings / from_bools / from_*_options |
LazyFrame::explain is untouched — it renders an actual query plan, not a
string alias. Inside the (now private) column layer, NumericColumn::from_int64s
/ from_doubles and ColumnStorage::from_builtin / from_numeric collapsed
into from_ints / from_floats and the enum variants.
compare_string_lex, is_decimal_int_literal, and format_scalar_literal
were re-exported by the facade in v0.5; they are gone from it. They — plus
escape_debug and the two literal parsers — now live in the private packages
internal/text / internal/literal, and types' fold_extremum /
double_fits_int64 in internal/numeric; downstream code cannot import any of
them, since MoonBit refuses a cross-module internal/ import outright. They are
not hidden-but-present in types: that package declares none of them any more.
Their behaviour is still part of the library's contract where it is observable:
string ordering is by Unicode code point (Series::sort / DataFrame::sort /
Scalar::lt), and literal parsing drives CSV / JSON type inference.
series' kernel functions (gather_series, reducer_for, key_cell, …, plus
ReduceOp / KeyCell) and io's read_csv_projected /
read_ndjson_projected take the other route: they stay in place, marked
#internal — still pub for the library's own use across packages, but absent
from the generated interfaces and warned about from another module. Use the
Series methods and DataFrame verbs built on them, and scan_csv /
scan_ndjson for projection push-down.
Series::storage / storage_kind / is_canonical / mean_opt and
DataFrame::to_scalar_matrix are no longer public API. They remain pub
because another package in the library needs them, but they are marked
#internal, so they are absent from the generated interface and calling them
from another module warns.
DataFrame::storage_kinds, Series::to_numeric / to_builtin and
DataFrame::to_numeric / to_builtin are gone outright rather than hidden.
Nothing selects a backend: a column takes the unboxed fast path when the
operation that produced it canonicalises and its content allows it (see
performance.md), and the constructors
are the closest thing to asking for one —
from_ints / from_floats build a Numeric column, the nullable
from_*_options a Builtin one.
They existed to expose the columnar backend, which moved to internal/column
in v0.6. Value-level access covers the user-facing cases: Series::get /
to_scalars and the typed constructors instead of a ColumnStorage,
DataFrame::rows / row / item instead of to_scalar_matrix, and
Series::mean (catching its error) instead of mean_opt.
| v0.5 | v0.6 |
|---|---|
HtmlOptions::default() |
HtmlOptions::HtmlOptions() |
HtmlOptions::default().with_max_rows(20).with_caption("S") |
HtmlOptions::HtmlOptions(max_rows=20, caption="S") |
df.to_html_with_options(opts) |
df.to_html(options=opts) |
df.to_markdown_with_limit(10) |
df.to_markdown(max_rows=10) |
JoinOptions::on(keys).with_how(Left) |
JoinOptions::on(keys, how=Left) |
JoinOptions::on(keys).with_coalesce(true) |
JoinOptions::on(keys, coalesce=true) |
JoinOptions::left_on(l).with_right_on(r) |
JoinOptions::left_on(l, right_on=r) |
JoinOptions::cross().with_suffix("_r") |
JoinOptions::cross(suffix="_r") |
ChartSpec::bar(x, y).with_color("region").with_title("T") |
ChartSpec::bar(x, y, color="region", title="T") |
Two shapes stop compiling by design. JoinOptions::left_on(keys) on its own is
gone — right_on~ is required, so a sided join always names both sides — and
there is no longer a way to set on and left_on / right_on on the same
options, which used to be a runtime InvalidOperation.
An options value is built like every other constructor —
let opts = HtmlOptions::HtmlOptions(max_rows=20), or inline at the call.
| v0.5 | v0.6 |
|---|---|
read_csv_with_options(path, opts) |
read_csv(path, options=opts) |
write_csv_with_options(path, df, opts) |
write_csv(path, df, options=opts) |
read_json_with_options(path, opts) |
read_json(path, options=opts) |
read_ndjson_with_options(path, opts) |
read_ndjson(path, options=opts) |
scan_csv_with_options(path, opts) |
scan_csv(path, options=opts) |
scan_ndjson_with_options(path, opts) |
scan_ndjson(path, options=opts) |
parse_csv_str(text, opts) |
parse_csv_str(text, options=opts) |
parse_json_records_str(text, opts) |
parse_json_str(text, options=opts) |
parse_ndjson_str(text, opts) |
parse_ndjson_str(text, options=opts) |
format_csv(df, opts) |
format_csv(df, options=opts) |
parse_csv_str(text, CsvReadOptions::CsvReadOptions()) |
parse_csv_str(text) |
The options parameter is optional and labelled, so it has to be named at the
call site — and a call that only wanted the defaults can drop it entirely.
read_csv_projected / read_ndjson_projected, the engine seam behind
projection push-down, keep their positional options.
No source-level migration steps. v0.5.8 is a fix patch: every v0.5.7 symbol and
signature is unchanged, the root facade .mbti is byte-for-byte identical, and
nothing is renamed, removed, re-signed, or given a new required match arm. Two
correctness fixes refine edge-case behaviour without touching any API — string
ordering now compares by Unicode code point (so supplementary-plane characters
such as emoji sort by their true scalar value; ordering within the Basic
Multilingual Plane is unchanged), and float-overflow detection during parsing no
longer depends on the standard library's error-message text (parse results are
unchanged). See the release notes.
No source-level migration steps. v0.5.7 is an internal-refactor patch: every
v0.5.6 symbol, signature, and behaviour is unchanged, and nothing is renamed,
removed, re-signed, or given a new required match arm. The implementation is
rewritten with current MoonBit syntax with no new or changed surface, so nothing
a consumer imports differs. (The expr / frame / lazy sub-package .mbti
files show #as_free_fn / #alias attributes on col / lit / limit, but
those symbols stay callable exactly as before — see the
release notes.)
No source-level migration steps. v0.5.6 is an additive patch: every v0.5.5
symbol and signature is unchanged, and nothing is renamed, removed, re-signed,
or given a new required match arm. The new surface is a moon bench benchmark
suite (test-scope only — nothing a consumer imports changes), a declared
supported_targets in moon.mod, and documentation corrections (see the
release notes).
No source-level migration steps. v0.5.5 is an additive patch: every v0.5.4
symbol and signature is unchanged, and nothing is renamed, removed, re-signed,
or given a new required match arm. The new surface is purely additive — two
introspection predicates, Series::is_canonical() and
BuiltinColumn::placeholders_normalized(), that assert internal representation
invariants (see the release notes).
No source-level migration steps. v0.5.4 is an additive patch: every v0.5.3
symbol and signature is unchanged, and nothing is renamed, removed, re-signed,
or given a new required match arm. The new surface is purely additive — the
API-consistency aliases (NumericColumn::from_ints / from_floats,
JoinOptions::with_left_on, DataFrame::limit) and the format_scalar_literal
facade re-export listed in the release notes.
No source-level migration steps: no renames, no signature changes, and no new
required match arms. v0.5.3 is a correctness and robustness patch, so the only
changes are behavioural fixes that code should not have depended on:
- A chain of
fill_null/fill_nannow builds in linear time instead of an exponentially-sized tree; the results are identical. - Out-of-range indices in the row-gather path (reached through
DataFrame::takeand the join planner) yield a null cell instead of panicking. Code that relied on the panic to flag a bad index should validate indices itself. Series::variance/stdsaturate to+infon intermediate Welford overflow rather than returning a spurious finite value.- A read projection (
read_csv_projected/read_ndjson_projected, and thelazyscans built on them) that names no column present in the header now falls back to reading the full file instead of yielding an empty frame.
Additive plus two behaviour fixes; no renames.
DataErrorgains aNullInNonNullable(String)variant. A new enum variant is the one change the post-v0.5 surface allows: an exhaustivematchoverDataErrorwithout a wildcard arm must add aNullInNonNullable(_)case.DataFrame::from_rowsnow raisesNullInNonNullable(name)when row data places a null in a field declarednullable = false(previously it built the frame silently). Declare the fieldnullable = true— the default, viaField::new— to keep the old behaviour.- Raw constructors (
Series/BuiltinColumn/NumericColumn'sfrom_ints/from_floats/from_bools/from_strings) now defensively copy their input array. Code that mutated the source array after construction to alter the column (the previously-documented footgun) no longer has that effect — mutate the array before constructing, or build a fresh one.
v0.5 is a pre-1.0 breaking release. (It was announced as the last one; v0.6 is
one more — the API-convergence release above — after which the public surface
evolves compatibly.) It
converges the eager and lazy APIs onto a single, Polars-shaped expression
engine. The duplicate *_exprs verbs, the closure filter, the AggSpec
reduction specs, the rich RowView, the per-type *_join methods, the
column-scalar reductions, and a tail of non-Polars names are all removed
outright — there are no deprecated aliases. Everything below is a pure rename
or a mechanical rewrite; for the feature side of the same release see
the release notes.
select / filter / agg / with_columns each now take an Array[Expr] (or
a single Expr), on both DataFrame and LazyFrame. The v0.4 *_exprs /
*_where twins that introduced the expression form are gone — the plain verb
is the expression form.
| v0.4 | v0.5 |
|---|---|
df.select(["region", "revenue"]) |
df.select([col("region"), col("revenue")]) — or df.select(cols(["region", "revenue"])) |
df.select_exprs([col("a") + col("b")]) |
df.select([col("a") + col("b")]) |
df.filter(row => row.get_int("x") > 0) |
df.filter(col("x").gt(lit_int(0))) |
df.filter_where(expr) |
df.filter(expr) |
grouped.agg([AggSpec::sum("x").with_alias("t")]) |
grouped.agg([col("x").sum().with_alias("t")]) |
grouped.agg_exprs([expr]) |
grouped.agg([expr]) |
df.with_column(series) |
df.with_columns([lit_series(series)]) |
lf.select_exprs(...) / lf.filter_where(...) |
lf.select(...) / lf.filter(...) |
The AggSpec struct and its AggKind enum (AggSpec::sum / mean / min /
max / count / with_alias) are removed; the equivalent reductions are the
Expr methods col("x").sum() / .mean() / .min() / .max() / .count(),
which additionally compose over a derived column — (col("revenue") - col("cost")).sum() — the thing AggSpec could not express.
Arbitrary row predicates. The old closure filter could run any MoonBit
code per row. Its reified replacement is the map_many escape hatch — a closure
over the row's cells as Scalars, carried by an inspectable Expr:
// v0.4
df.filter(row => row.get_string("product") == "widget")
// v0.5
df.filter(
map_many(label="is_widget", [col("product")], cells => Scalar::Bool(
cells[0].as_string() == "widget",
)),
)map_elements is the single-input form: col("q").map_elements(label="...", s => ...).
The key-bearing verbs now name their keys with Expr, so a key can be a derived
column, not just a name. sort_by is renamed sort to match Polars.
| v0.4 | v0.5 |
|---|---|
df.sort_by([("revenue", Desc, NullsLast)]) |
df.sort([(col("revenue"), Desc, NullsLast)]) |
df.group_by(["region"]) |
df.group_by([col("region")]) |
df.drop(["tmp"]) |
df.drop([col("tmp")]) |
df.drop_nulls_in(["revenue"]) |
df.drop_nulls(subset=[col("revenue")]) |
lf.sort_by(...) / lf.group_by([name]) |
lf.sort(...) / lf.group_by([col(name)]) |
drop_nulls() with no argument is unchanged (drop every row with a null in any
column); it just gained an optional subset, which retired the separate
drop_nulls_in. rename is unchanged — it takes Array[(String, String)],
matching Polars' dict form, not expressions.
The per-type convenience joins are removed; join with a JoinOptions is the
only form (as in Polars). Keys are Expr, and left_on / right_on support
differently-named or derived keys.
| v0.4 | v0.5 |
|---|---|
left.inner_join(right, ["id"]) |
left.join(right, JoinOptions::on([col("id")])) — inner is the default how |
left.left_join(right, ["id"]) |
left.join(right, JoinOptions::on([col("id")]).with_how(Left)) |
left.right_join(...) / left.outer_join(...) |
.with_how(Right) / .with_how(Outer) |
left.cross_join(right) |
left.join(right, JoinOptions::cross()) |
JoinOptions::on(["id"]) |
JoinOptions::on([col("id")]) |
| (no equivalent) | JoinOptions::left_on([col("a")]).with_right_on([col("b")]) for differently-named keys |
with_how / with_coalesce / with_suffix and the null-key / NaN-key /
suffix semantics are unchanged. One behaviour change: the coalesce = None
default now follows Polars per how — a Left / Right join coalesces its
key into one column instead of keeping both (Inner already coalesced, Outer
still keeps both); pass with_coalesce(false) for the old two-column
Left / Right output.
The rich RowView (and the unchecked row_view) are removed in favour of
Polars' positional row access. df.row(i) now returns an Array[Scalar] (by
column order); df.rows() returns every row. For a single typed value, read the
column and index it, then narrow the Scalar.
| v0.4 | v0.5 |
|---|---|
df.row(i) → RowView |
df.row(i) → Array[Scalar] |
df.row_view(i) (unchecked) |
removed — use df.row(i) |
df.row_view(i).get_int("c") |
df.get_column("c").get(i).as_int() — likewise as_float / as_bool / as_string |
df.row(i).get_string("c") |
df.get_column("c").get(i).as_string() |
view.is_null("c") |
df.get_column("c").get(i).is_null() |
| (iterate rows) | df.rows() → Array[Array[Scalar]] |
df.sum(col) returning a scalar is removed (it has no Polars analogue). Polars'
two forms take its place: df[col].sum() for a single scalar — here
df.get_column(col).sum() — and the no-argument df.sum() reducing every
numeric column to a one-row DataFrame.
| v0.4 | v0.5 |
|---|---|
df.sum("revenue") → Scalar |
df.get_column("revenue").sum() → Scalar |
df.mean("revenue") → Double |
df.get_column("revenue").mean() → Double |
df.min("x") / df.max("x") / df.count("x") |
df.get_column("x").min() / .max() / .count() |
| (no equivalent) | df.sum() / mean() / min() / max() / count() → one-row DataFrame |
The frame-wide df.sum() reduces only Int / Float columns (a Bool /
String column becomes a Null cell of its source dtype); df.count() is the
per-column non-null count. Note df.get_column(c).sum() raises on a
non-numeric column, while the frame-wide df.sum() tolerates it by nulling — the
two reductions differ on purpose.
The per-column df.fill_null(name, value) is removed; per-column filling is now
an Expr method, and there is a new whole-frame form.
| v0.4 | v0.5 |
|---|---|
df.fill_null("note", Scalar::String("n/a")) |
df.with_columns([col("note").fill_null(lit_str("n/a"))]) |
| (no equivalent) | df.fill_null(Scalar::Int(0)) — fills the null cells of every dtype-compatible column |
Series::fill_null(Scalar) is unchanged. The Expr form is more capable than
the old frame method: the fill value is any Expr (a literal, another column for
a coalesce, or a computed tree), and Int / Float operands unify.
replace_column is removed; with_columns([lit_series(...)]) replaces a column
by name. Rename the series to the target name first if it differs.
| v0.4 | v0.5 |
|---|---|
df.replace_column("x", series) |
df.with_columns([lit_series(series.rename("x"))]) |
Two behaviour differences, by design: where the old method raised
ColumnNotFound on a missing name, with_columns appends the column; and
where it raised LengthMismatch on any off-length series, lit_series
broadcasts a length-1 series.
The last non-Polars public names are aligned — mechanical renames, or a fold
into cast.
| v0.4 | v0.5 |
|---|---|
series.min_value() / max_value() |
series.min() / series.max() |
series.take([...]) |
series.gather([...]) |
series.unique_count() |
series.n_unique() |
series.to_int() / to_float() / to_string_series() |
series.cast(DataType::Int) / cast(DataType::Float) / cast(DataType::String) |
series.null_rate() |
removed — compute series.null_count() / series.len() |
series.describe() |
removed — wrap in a frame: DataFrame::new([series]).describe() |
df.get(i, "c") |
df.item(i, "c") |
@io.format_csv_str(df, opts) |
@io.format_csv(df, opts) |
The same min_value → min, max_value → max, and to_int / to_float →
cast renames apply to the column backend types (NumericColumn,
BuiltinColumn, ColumnStorage) for callers who reach them directly;
to_string_column is kept (it returns a BuiltinColumn, not a cast's Self).
Series was extracted from frame into a new series package so the
expression layer can build on the per-column unit. Facade users are unaffected —
@moonframe.Series still names the same type, with the same constructors and
methods. Only code that imported the type directly from frame needs the
new path.
| v0.4 | v0.5 |
|---|---|
ihb2032/MoonFrame/frame.Series |
ihb2032/MoonFrame/series.Series |
facade @moonframe.Series |
unchanged |
v0.5 also adds, with nothing to migrate: the map_elements / map_many
closure escape hatch; the aggregations std / variance / median /
n_unique / first / last; the Expr string namespace (str_to_uppercase /
str_contains / str_replace / …); lit_series and the cols name helper;
DataFrame::unique() (first-appearance row dedup); and the lazy file sources
scan_csv / scan_ndjson (with _with_options variants) with projection
pushdown.
sort treats a Float NaN as missing (ordered by the tuple's
NullOrder), not as a value. This is the only place v0.5 knowingly differs from
Polars, where NaN is a value that sorts last independently of nulls_last.
Everything else above matches Polars' shape and behaviour.
Additive — nothing to change. v0.4 only adds symbols: the new expr
package (Expr, col / lit_* / when, the operators and methods), the new
lazy package (LazyFrame / LazyGroupBy, lazy_frame), and new DataFrame
/ GroupedDataFrame methods (with_columns / select_exprs / filter_where
/ agg_exprs). No v0.2 / v0.3 type, method, or enum variant changed, so
existing code compiles and behaves identically. The two new public
sub-packages are available directly for callers who want a slice of the
surface, while callers who import only the facade ihb2032/MoonFrame get the
same symbols there. (The Series-into-its-own-package split, which will
touch existing code, is deferred to v0.5.)
v0.3 is a pre-1.0 breaking release. The source-level breaks:
| v0.2 | v0.3 |
|---|---|
Series::storage() -> @column.BuiltinColumn |
-> @column.ColumnStorage; the .data() / .validity() reading surface is unchanged, so column-reading call sites still compile. Use .to_builtin() when you need the concrete BuiltinColumn |
Series::new(name, BuiltinColumn) |
Series::new(name, ColumnStorage); pass ColumnStorage::from_builtin(col), or keep Series::from_builtin(name, col) (signature unchanged) |
pub(all) enum JoinType { Inner; Left; Cross } |
gained Right / Outer; an exhaustive match over JoinType must now handle the two new variants |
The CSV / JSON / NDJSON *ReadOptions structs also gained pub(all) fields
(read resilience — on_parse_error, plus CSV's allow_nonfinite_floats): a
full struct literal must add them or switch to ::default(). The defaults
reproduce the prior behaviour exactly.
| v0.1 | v0.2 |
|---|---|
@ops.select(df, names) (free function) |
df.select(names) (method) |
op(df, ...) -> Result[T, DataError] + .bind / .map / .unwrap |
df.op(...) -> T raise DataError, chained directly |
pattern-match Ok(x) / Err(e) on the result |
call directly in a raise context, or Ok(expr) catch { e => Err(e) } for a Result |
filter_try(df, row => row.get_int("x").map(v => v > 0)) |
df.filter(row => row.get_int("x") > 0) |
sort_by(df, spec) / sort_by_many(df, specs) |
df.sort_by([(col, order, nulls), ...]) |
Series::min() / max() (Result-wrapped) |
Series::min_value() / max_value() (total) |
@io.to_markdown(df) |
df.to_markdown() |
import ... @ops |
gone — verbs live on DataFrame in @frame |
format_csv_str / format_json_records / parse_csv_str / read_csv /
write_csv and the JSON / NDJSON equivalents are still io free functions (the
read_* / write_* / parse_* ones now raise; the format_* ones are total
and return a String).