diff --git a/crates/nano-arrow/Cargo.toml b/crates/nano-arrow/Cargo.toml index 110db3d2c12b..be7154a27587 100644 --- a/crates/nano-arrow/Cargo.toml +++ b/crates/nano-arrow/Cargo.toml @@ -74,7 +74,7 @@ arrow-array = { workspace = true, optional = true } arrow-buffer = { workspace = true, optional = true } arrow-data = { workspace = true, optional = true } arrow-schema = { workspace = true, optional = true } -parquet2 = { workspace = true, optional = true, default-features = false, features = ["async"] } +parquet2 = { workspace = true, optional = true, features = ["async"] } [dev-dependencies] avro-rs = { version = "0.13", features = ["snappy"] } diff --git a/crates/nano-arrow/src/io/ipc/read/deserialize.rs b/crates/nano-arrow/src/io/ipc/read/deserialize.rs index 40d04dd14026..e5b1014c278d 100644 --- a/crates/nano-arrow/src/io/ipc/read/deserialize.rs +++ b/crates/nano-arrow/src/io/ipc/read/deserialize.rs @@ -9,7 +9,7 @@ use super::{Dictionaries, IpcBuffer, Node}; use crate::array::*; use crate::datatypes::{DataType, Field, PhysicalType}; use crate::io::ipc::IpcField; -use crate::{match_integer_type, with_match_primitive_type, with_match_primitive_type_full}; +use crate::{match_integer_type, with_match_primitive_type_full}; #[allow(clippy::too_many_arguments)] pub fn read( diff --git a/crates/nano-arrow/src/util/macros.rs b/crates/nano-arrow/src/util/macros.rs index e1274bbc441f..b09a9d5d5473 100644 --- a/crates/nano-arrow/src/util/macros.rs +++ b/crates/nano-arrow/src/util/macros.rs @@ -26,6 +26,7 @@ macro_rules! with_match_primitive_type_full {( ) => ({ macro_rules! __with_ty__ {( $_ $T:ident ) => ( $($body)* )} use $crate::datatypes::PrimitiveType::*; + use $crate::types::{f16}; match $key_type { Int8 => __with_ty__! { i8 }, Int16 => __with_ty__! { i16 }, @@ -36,6 +37,7 @@ macro_rules! with_match_primitive_type_full {( UInt32 => __with_ty__! { u32 }, UInt64 => __with_ty__! { u64 }, Int128 => __with_ty__! { i128 }, + Float16 => __with_ty__! { f16 }, Float32 => __with_ty__! { f32 }, Float64 => __with_ty__! { f64 }, _ => panic!("operator does not support primitive `{:?}`", diff --git a/crates/polars-error/src/lib.rs b/crates/polars-error/src/lib.rs index 4c7b005d6183..39a4b658ba34 100644 --- a/crates/polars-error/src/lib.rs +++ b/crates/polars-error/src/lib.rs @@ -88,10 +88,7 @@ impl From for PolarsError { #[cfg(feature = "parquet2")] impl From for PolarsError { fn from(err: parquet2::error::Error) -> Self { - PolarsError::Io(std::io::Error::new( - std::io::ErrorKind::Other, - format!("parquet error: {err:?}"), - )) + polars_err!(ComputeError: "parquet error: {err:?}") } } @@ -118,10 +115,7 @@ impl From for PolarsError { #[cfg(feature = "arrow-format")] impl From for PolarsError { fn from(err: arrow_format::ipc::planus::Error) -> Self { - PolarsError::Io(std::io::Error::new( - std::io::ErrorKind::Other, - format!("flatbuffers error: {err:?}"), - )) + polars_err!(ComputeError: "parquet error: {err:?}") } } diff --git a/py-polars/polars/exceptions.py b/py-polars/polars/exceptions.py index 675b1348e4b8..a4e5b81a6201 100644 --- a/py-polars/polars/exceptions.py +++ b/py-polars/polars/exceptions.py @@ -98,8 +98,9 @@ class UnsuitableSQLError(ValueError): """Exception raised when unsuitable SQL is given to a database method.""" -class ArrowError(Exception): # type: ignore[no-redef] - """deprecated will be removed""" +class ArrowError(Exception): + """deprecated will be removed.""" + __all__ = [ "ArrowError", diff --git a/py-polars/src/lib.rs b/py-polars/src/lib.rs index f90bcfc23d34..06c5763c91e9 100644 --- a/py-polars/src/lib.rs +++ b/py-polars/src/lib.rs @@ -51,9 +51,8 @@ use pyo3::wrap_pyfunction; use crate::conversion::Wrap; use crate::dataframe::PyDataFrame; use crate::error::{ - ColumnNotFoundError, ComputeError, DuplicateError, InvalidOperationError, - NoDataError, OutOfBoundsError, PyPolarsErr, SchemaError, SchemaFieldNotFoundError, - StructFieldNotFoundError, + ColumnNotFoundError, ComputeError, DuplicateError, InvalidOperationError, NoDataError, + OutOfBoundsError, PyPolarsErr, SchemaError, SchemaFieldNotFoundError, StructFieldNotFoundError, }; use crate::expr::PyExpr; use crate::functions::string_cache::PyStringCacheHolder; diff --git a/py-polars/tests/unit/dataframe/test_df.py b/py-polars/tests/unit/dataframe/test_df.py index 59051d2ddd4c..6b368a47d336 100644 --- a/py-polars/tests/unit/dataframe/test_df.py +++ b/py-polars/tests/unit/dataframe/test_df.py @@ -500,7 +500,7 @@ def test_file_buffer() -> None: f.write(b"1,2,3,4,5,6\n7,8,9,10,11,12") f.seek(0) # check if not fails on TryClone and Length impl in file.rs - with pytest.raises(OSError): + with pytest.raises(pl.ComputeError): pl.read_parquet(f) diff --git a/py-polars/tests/unit/datatypes/test_temporal.py b/py-polars/tests/unit/datatypes/test_temporal.py index 12e73402bd74..29bb48f82247 100644 --- a/py-polars/tests/unit/datatypes/test_temporal.py +++ b/py-polars/tests/unit/datatypes/test_temporal.py @@ -12,7 +12,7 @@ import polars as pl from polars.datatypes import DATETIME_DTYPES, DTYPE_TEMPORAL_UNITS, TEMPORAL_DTYPES -from polars.exceptions import ArrowError, ComputeError, TimeZoneAwareConstructorWarning +from polars.exceptions import ComputeError, TimeZoneAwareConstructorWarning from polars.testing import ( assert_frame_equal, assert_series_equal, @@ -2177,7 +2177,8 @@ def test_replace_time_zone_ambiguous_with_use_earliest( def test_replace_time_zone_ambiguous_raises() -> None: ts = pl.Series(["2018-10-28 02:30:00"]).str.strptime(pl.Datetime) with pytest.raises( - pl.ComputeError, match="Please use `ambiguous` to tell how it should be localized" + pl.InvalidOperationError, + match="Please use `ambiguous` to tell how it should be localized", ): ts.dt.replace_time_zone("Europe/Brussels") diff --git a/py-polars/tests/unit/namespaces/test_strptime.py b/py-polars/tests/unit/namespaces/test_strptime.py index 878078b56747..15271811b1fe 100644 --- a/py-polars/tests/unit/namespaces/test_strptime.py +++ b/py-polars/tests/unit/namespaces/test_strptime.py @@ -12,7 +12,7 @@ import pytest import polars as pl -from polars.exceptions import ArrowError, ComputeError, TimeZoneAwareConstructorWarning +from polars.exceptions import ComputeError, TimeZoneAwareConstructorWarning from polars.testing import assert_series_equal if TYPE_CHECKING: @@ -459,14 +459,14 @@ def test_strptime_invalid_timezone() -> None: def test_to_datetime_ambiguous_or_non_existent() -> None: with pytest.raises( - ArrowError, + pl.InvalidOperationError, match="datetime '2021-11-07 01:00:00' is ambiguous in time zone 'US/Central'", ): pl.Series(["2021-11-07 01:00"]).str.to_datetime( time_unit="us", time_zone="US/Central" ) with pytest.raises( - ArrowError, + pl.InvalidOperationError, match="datetime '2021-03-28 02:30:00' is non-existent in time zone 'Europe/Warsaw'", ): pl.Series(["2021-03-28 02:30"]).str.to_datetime( @@ -643,7 +643,7 @@ def test_to_datetime_use_earliest(exact: bool) -> None: ) expected = datetime(2020, 10, 25, 1, fold=1, tzinfo=ZoneInfo("Europe/London")) assert result == expected - with pytest.raises(ArrowError): + with pytest.raises(pl.InvalidOperationError): pl.Series(["2020-10-25 01:00"]).str.to_datetime( time_zone="Europe/London", exact=exact, @@ -670,7 +670,7 @@ def test_strptime_use_earliest(exact: bool) -> None: ) expected = datetime(2020, 10, 25, 1, fold=1, tzinfo=ZoneInfo("Europe/London")) assert result == expected - with pytest.raises(ArrowError): + with pytest.raises(pl.InvalidOperationError): pl.Series(["2020-10-25 01:00"]).str.strptime( pl.Datetime("us", "Europe/London"), exact=exact,