Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Use of Features For arrow-json with Lexical #6959

Open
Alexhuszagh opened this issue Jan 9, 2025 · 1 comment · May be fixed by #6960
Open

Incorrect Use of Features For arrow-json with Lexical #6959

Alexhuszagh opened this issue Jan 9, 2025 · 1 comment · May be fixed by #6960
Labels
development-process Related to development process of arrow-rs enhancement Any new improvement worthy of a entry in the changelog

Comments

@Alexhuszagh
Copy link

Describe the bug

Currently, arrow-json depends on lexical-core, but disables all default features without enabling the writers or parsers. This works, because arrow-cast enables these features and arrow-json depends on arrow-cast.

To Reproduce

Disable the features in arrow-cast, and modify to another implementation (I trivially use fmt::Display and to_string) in a fork and this leads to build errors:

error[E0425]: cannot find function `write` in crate `lexical_core`
   --> arrow-json\src\writer\encoder.rs:258:39
    |
258 |                         lexical_core::write(self, buf)
    |                                       ^^^^^ not found in `lexical_core`
...
265 | float_encode!(f32, f64);

error[E0599]: no associated item named `FORMATTED_SIZE` found for type `i8` in the current scope
   --> arrow-json\src\writer\encoder.rs:229:42
    |
229 |                 type Buffer = [u8; Self::FORMATTED_SIZE];
    |                                          ^^^^^^^^^^^^^^ associated item not found in `i8`
...
242 | integer_encode!(i8, i16, i32, i64, u8, u16, u32, u64);
    | ----------------------------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `integer_encode` (in Nightly builds, run with -Z macro-backtrace for more info)

arrow-cast, however, builds successfully, as expected.

Expected behavior

Both crates should be able to build without depending on the enabled features in a dependency while separately relying on but not enabling those features.

A full patch is to also enable those features in arrow-json:

diff --git a/arrow-json/Cargo.toml b/arrow-json/Cargo.toml
index 564cb943..56f18f6a 100644
--- a/arrow-json/Cargo.toml
+++ b/arrow-json/Cargo.toml
@@ -45,7 +45,7 @@ num = { version = "0.4", default-features = false, features = ["std"] }
 serde = { version = "1.0", default-features = false }
 serde_json = { version = "1.0", default-features = false, features = ["std"] }
 chrono = { workspace = true }
-lexical-core = { version = "1.0", default-features = false}
+lexical-core = { version = "1.0", default-features = false, features = ["write-integers", "write-floats", "parse-integers", "parse-floats"] }

 [dev-dependencies]
 flate2 = { version = "1", default-features = false, features = ["rust_backend"] }
@@ -59,4 +59,3 @@ rand = { version = "0.8", default-features = false, features = ["std", "std_rng"
 [[bench]]
 name = "serde"
 harness = false
@Alexhuszagh Alexhuszagh added the bug label Jan 9, 2025
@tustvold tustvold added enhancement Any new improvement worthy of a entry in the changelog development-process Related to development process of arrow-rs and removed bug labels Jan 9, 2025
@tustvold
Copy link
Contributor

tustvold commented Jan 9, 2025

Relabelling based on #6960 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development-process Related to development process of arrow-rs enhancement Any new improvement worthy of a entry in the changelog
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants