This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-julia.git
The following commit(s) were added to refs/heads/main by this push:
new d80fc68 Fix case where metadata is provided but empty (#276)
d80fc68 is described below
commit d80fc68b49dd4ff2924c22217d79615762a67732
Author: Jacob Quinn <[email protected]>
AuthorDate: Fri Jan 21 22:26:20 2022 -0700
Fix case where metadata is provided but empty (#276)
Fixes #253. Just a simple fix to the `toidict` utility function to
account for the empty case. This would happen when metadata was
_provided_ for a table/column, but was empty, which would probably be a
common case in programmatic environments for reading/writing arrow.
---
src/utils.jl | 1 +
test/runtests.jl | 3 +++
2 files changed, 4 insertions(+)
diff --git a/src/utils.jl b/src/utils.jl
index 6fc6f74..7151579 100644
--- a/src/utils.jl
+++ b/src/utils.jl
@@ -199,6 +199,7 @@ toidict(x::Base.ImmutableDict) = x
# ref https://github.com/JuliaData/Arrow.jl/pull/238#issuecomment-919415809
function toidict(pairs)
+ isempty(pairs) && return Base.ImmutableDict{String, String}()
dict = Base.ImmutableDict(first(pairs))
for pair in Iterators.drop(pairs, 1)
dict = Base.ImmutableDict(dict, pair)
diff --git a/test/runtests.jl b/test/runtests.jl
index 51710a7..09d3d6e 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -488,6 +488,9 @@ t2 = (
)
@test_throws ArgumentError collect(Arrow.Stream([Arrow.tobuffer(t),
Arrow.tobuffer(t2)]))
+# https://github.com/apache/arrow-julia/issues/253
+@test Arrow.toidict(Pair{String, String}[]) == Base.ImmutableDict{String,
String}()
+
end # @testset "misc"
end