Skip to content

(dyn ArrayFormatterFactory + 'static) can't be safely shared between threads #8875

@alamb

Description

@alamb

Describe the bug

When I tried the new version of arrow with DataFusion in this PR:

Compilation fails like this:

 Compiling datafusion-sql v51.0.0 (/Users/andrewlamb/Software/datafusion/datafusion/sql)
error[E0277]: `(dyn ArrayFormatterFactory + 'static)` cannot be shared between threads safely
   --> datafusion/physical-expr/src/expressions/cast.rs:130:23
    |
130 | impl PhysicalExpr for CastExpr {
    |                       ^^^^^^^^ `(dyn ArrayFormatterFactory + 'static)` cannot be shared between threads safely
    |
    = help: within `CastExpr`, the trait `Sync` is not implemented for `(dyn ArrayFormatterFactory + 'static)`
    = note: required because it appears within the type `&'static (dyn ArrayFormatterFactory + 'static)`
note: required because it appears within the type `Option<&'static (dyn ArrayFormatterFactory + 'static)>`
   --> /Users/andrewlamb/.rustup/toolchains/1.91.0-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/option.rs:594:10
    |
594 | pub enum Option<T> {
    |          ^^^^^^
note: required because it appears within the type `arrow::util::display::FormatOptions<'static>`
   --> /Users/andrewlamb/.cargo/git/checkouts/arrow-rs-a228b2f48bc25539/f7d41c8/arrow-cast/src/display.rs:63:12
    |
 63 | pub struct FormatOptions<'a> {
    |            ^^^^^^^^^^^^^
note: required because it appears within the type `CastOptions<'static>`
   --> /Users/andrewlamb/.cargo/git/checkouts/arrow-rs-a228b2f48bc25539/f7d41c8/arrow-cast/src/cast/mod.rs:76:12
    |
 76 | pub struct CastOptions<'a> {
    |            ^^^^^^^^^^^
note: required because it appears within the type `CastExpr`
   --> datafusion/physical-expr/src/expressions/cast.rs:46:12

To Reproduce
See apache/datafusion#18820

Expected behavior
I should be able to keep on compiling what previously worked
Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions