Skip to content

Commit 0e98c07

Browse files
authored
Recommend using package-specific prefix with arrowname (#541)
Documentation: recommend package-specific prefix with arrowname
1 parent 472baa0 commit 0e98c07

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

docs/src/manual.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,12 @@ end
111111

112112
# overload interface method for custom type Person; return a symbol as the "name"
113113
# this instructs Arrow.write what "label" to include with a column with this custom type
114-
ArrowTypes.arrowname(::Type{Person}) = :Person
115-
# overload JuliaType on `Val{:Person}`, which is like a dispatchable string
114+
const NAME = Symbol("JuliaLang.MyPackage.Person")
115+
ArrowTypes.arrowname(::Type{Person}) = NAME
116+
# overload JuliaType on `Val{NAME}`, which is like a dispatchable string
116117
# return our custom *type* Person; this enables Arrow.Table to know how the "label"
117118
# on a custom column should be mapped to a Julia type and deserialized
118-
ArrowTypes.JuliaType(::Val{:Person}) = Person
119+
ArrowTypes.JuliaType(::Val{NAME}) = Person
119120

120121
table = (col1=[Person(1, "Bob"), Person(2, "Jane")],)
121122
io = IOBuffer()
@@ -162,7 +163,7 @@ using Intervals
162163
table = (col = [
163164
Interval{Closed,Unbounded}(1,nothing),
164165
],)
165-
const NAME = Symbol("JuliaLang.Interval")
166+
const NAME = Symbol("JuliaLang.Intervals.Interval")
166167
ArrowTypes.arrowname(::Type{Interval{T, L, R}}) where {T, L, R} = NAME
167168
const LOOKUP = Dict(
168169
"Closed" => Closed,

src/ArrowTypes/src/ArrowTypes.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ toarrow(x) = x
100100
ArrowTypes.arrowname(T) = Symbol(name)
101101
102102
Interface method to define the logical type "label" for a custom Julia type `T`. Names will be global for an entire arrow dataset,
103-
and conventionally, custom types will just use their type name along with a Julia-specific prefix; for example, for a custom type
104-
`Foo`, I would define `ArrowTypes.arrowname(::Type{Foo}) = Symbol("JuliaLang.Foo")`. This ensures other language implementations
105-
won't get confused and are safe to ignore the logical type label.
103+
and conventionally, custom types will just use their type name along with a Julia- and package-specific prefix; for example,
104+
for a custom type `Foo`, I would define `ArrowTypes.arrowname(::Type{Foo}) = Symbol("JuliaLang.MyPackage.Foo")`.
105+
This ensures other language implementations won't get confused and are safe to ignore the logical type label.
106106
When arrow stores non-native data, it must still be _stored_ as a native data type, but can have type metadata tied to the data that
107107
labels the original _logical_ type it originated from. This enables the conversion of native data back to the logical type when
108108
deserializing, as long as the deserializer has the same definitions when the data was serialized. Namely, the current Julia

0 commit comments

Comments
 (0)