Skip to content

Write to Arrow IPC Stream Format

Source code

Description

Write to Arrow IPC Stream Format

Usage

<DataFrame>$write_ipc_stream(
  path,
  ...,
  compression = c("zstd", "lz4", "uncompressed"),
  compat_level = c("newest", "oldest")
)

Arguments

path A character. File path to which the file should be written.
These dots are for future extensions and must be empty.
compression Determines the compression algorithm. In Polars 1.16, omitting this argument uses “zstd” and emits a deprecation warning. The default changes to “uncompressed” in Polars 2.0; pass an explicit value to choose either behavior without a warning. Must be one of:
  • “uncompressed” or NULL: Write an uncompressed Arrow file.
  • “lz4”: Fast compression/decompression.
  • “zstd”: Good compression performance.
compat_level Determines the compatibility level when exporting Polars’ internal data structures. When specifying a new compatibility level, Polars exports its internal data structures that might not be interpretable by other Arrow implementations. The level can be specified as the name (e.g., “newest”) or as a scalar integer (Currently, 0 and 1 are supported).
  • “newest” [Experimental] (default): Use the highest level, currently same as 1 (Low compatibility).
  • “oldest”: Same as 0 (High compatibility).

Value

NULL invisibly.

Examples

library("polars")


tmpf <- tempfile(fileext = ".arrows")
as_polars_df(mtcars)$write_ipc_stream(tmpf, compression = "zstd")

nanoarrow::read_nanoarrow(tmpf)
#> <nanoarrow_array_stream struct<mpg: double, cyl: double, disp: double, hp: double, drat: double, wt: double, qsec: double, vs: double, am: double, gear: double, carb: double>>
#>  $ get_schema:function ()  
#>  $ get_next  :function (schema = x$get_schema(), validate = TRUE)  
#>  $ release   :function ()