arrow-julia icon indicating copy to clipboard operation
arrow-julia copied to clipboard

Avoid extending `Type` from Base on Julia 1.12

Open ararslan opened this issue 8 months ago • 2 comments
trafficstars

The internal Flatbuf module defines a function called Type. On Julia 1.12, defining a new function by defining methods is insufficient to distinguish it from defining new constructor methods for a visible type of the same name. It's now necessary to forward-declare the function to ensure it takes precedence over the other visible binding. Without doing so, Base.Type is extended in Flatbuf instead.

On current main with Julia v1.13.0-DEV.122:

julia> using Arrow
Info Given Arrow was explicitly requested, output will be shown live
WARNING: Constructor for type "Type" was extended in `Flatbuf` without explicit qualification or import.
  NOTE: Assumed "Type" refers to `Base.Type`. This behavior is deprecated and may differ in future versions.
  NOTE: This behavior may have differed in Julia versions prior to 1.12.
  Hint: If you intended to create a new generic function of the same name, use `function Type end`.
  Hint: To silence the warning, qualify `Type` as `Base.Type` in the method signature or explicitly `import Base: Type`.
Precompiling Arrow finished.
  1 dependency successfully precompiled in 4 seconds. 47 already precompiled.
  1 dependency had output during precompilation:
┌ Arrow
│  [Output was shown above]
└

julia> methods(Type)
# 2 methods for type constructor:
 [1] Type(b::UInt8)
     @ Arrow.Flatbuf ~/Projects/julia-packages/arrow-julia/src/metadata/Schema.jl:489
 [2] Type(::Type{T}) where T
     @ Arrow.Flatbuf ~/Projects/julia-packages/arrow-julia/src/metadata/Schema.jl:519

julia> Arrow.Flatbuf.Type === Type
[ Warning: Type is defined in Core and is not public in Arrow.Flatbuf
true

With this PR, the output is the same because of https://github.com/JuliaLang/julia/issues/57546 but will have the correct behavior once that issue is fixed.

ararslan avatar Mar 01 '25 01:03 ararslan

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 86.96%. Comparing base (3712291) to head (9eb80c1). :warning: Report is 32 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #543      +/-   ##
==========================================
- Coverage   87.43%   86.96%   -0.48%     
==========================================
  Files          26       27       +1     
  Lines        3288     3398     +110     
==========================================
+ Hits         2875     2955      +80     
- Misses        413      443      +30     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov-commenter avatar Apr 04 '25 15:04 codecov-commenter

Same problem on Julia 1.12-beta3

ufechner7 avatar May 14 '25 04:05 ufechner7

Could you rebase on main to re-run CI?

kou avatar Aug 19 '25 00:08 kou

@kou, I've rebased.

ararslan avatar Aug 21 '25 06:08 ararslan

Hmm... CI isn't executed... Could you re-rebase...?

kou avatar Aug 21 '25 07:08 kou

Done, but I still don't see CI status. Is the repository configured such that CI is not run on PRs from forks?

ararslan avatar Aug 21 '25 22:08 ararslan

Thanks. I can approve CI execution for "first-time contributor" now. I've approved now. Let's see the CI result with this change.

kou avatar Aug 22 '25 01:08 kou

Looks like CI fails on Julia nightly with multiple threads, but not in a way that could plausibly be related to the changes here, so I think we're okay.

ararslan avatar Aug 22 '25 22:08 ararslan

@quinnj @ericphanson @baumgold Can we merge this?

kou avatar Aug 25 '25 01:08 kou

@quinnj @ericphanson @baumgold I'll merge this in the next week if nobody objects it.

kou avatar Sep 08 '25 23:09 kou

@kou please merge since 1.12 is now RC2 ❤️

palday avatar Sep 18 '25 21:09 palday

Merged. Should we release a new version before Julia 1.12 release?

kou avatar Sep 19 '25 00:09 kou

@kou yes!

palday avatar Sep 19 '25 02:09 palday

OK. Let's discuss it in #567.

kou avatar Sep 19 '25 02:09 kou