Skip to content

Commit

Permalink
Added tests for Pathname to read_parquet and write_parquet
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Mar 18, 2024
1 parent 5ac38fd commit 12d9186
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/polars/data_frame.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ def write_ipc(file, compression: "uncompressed")

# Write to Apache Parquet file.
#
# @param file [String, StringIO]
# @param file [String, Pathname, StringIO]
# File path to which the file should be written.
# @param compression ["lz4", "uncompressed", "snappy", "gzip", "lzo", "brotli", "zstd"]
# Choose "zstd" for good compression performance.
Expand Down
2 changes: 1 addition & 1 deletion lib/polars/io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ def read_ipc(

# Read into a DataFrame from a parquet file.
#
# @param source [Object]
# @param source [String, Pathname, StringIO]
# Path to a file or a file-like object.
# @param columns [Object]
# Columns to select. Accepts a list of column indices (starting at zero) or a list
Expand Down
15 changes: 15 additions & 0 deletions test/parquet_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ def test_read_parquet_file
assert_frame expected, df
end

def test_read_parquet_pathname
require "pathname"

df = Polars.read_parquet(Pathname.new("test/support/data.parquet"))
expected = Polars::DataFrame.new({"a" => [1, 2, 3], "b" => ["one", "two", "three"]})
assert_frame expected, df
end

def test_read_parquet_io
require "stringio"

Expand Down Expand Up @@ -43,6 +51,13 @@ def test_write_parquet
assert_nil df.write_parquet(temp_path)
end

def test_write_parquet_pathname
require "pathname"

df = Polars::DataFrame.new({"a" => [1, 2, 3], "b" => ["one", "two", "three"]})
assert_nil df.write_parquet(Pathname.new(temp_path))
end

def test_write_parquet_io
require "stringio"

Expand Down

0 comments on commit 12d9186

Please sign in to comment.