You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by om...@apache.org on 2023/01/29 04:50:00 UTC

[arrow-julia] branch cv/multi-dimensional-default created (now c1bd687)

This is an automated email from the ASF dual-hosted git repository.

omus pushed a change to branch cv/multi-dimensional-default
in repository https://gitbox.apache.org/repos/asf/arrow-julia.git


      at c1bd687  Support default for multi-dimensional arrays

This branch includes the following new commits:

     new c1bd687  Support default for multi-dimensional arrays

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[arrow-julia] 01/01: Support default for multi-dimensional arrays

Posted by om...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

omus pushed a commit to branch cv/multi-dimensional-default
in repository https://gitbox.apache.org/repos/asf/arrow-julia.git

commit c1bd68702fa7c9d02eb42400cb5d1e39e2ac9678
Author: Curtis Vogt <cu...@gmail.com>
AuthorDate: Sat Jan 28 22:30:14 2023 -0600

    Support default for multi-dimensional arrays
---
 src/ArrowTypes/src/ArrowTypes.jl | 4 ++--
 src/ArrowTypes/test/tests.jl     | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/ArrowTypes/src/ArrowTypes.jl b/src/ArrowTypes/src/ArrowTypes.jl
index f4f9e39..abb3a4b 100644
--- a/src/ArrowTypes/src/ArrowTypes.jl
+++ b/src/ArrowTypes/src/ArrowTypes.jl
@@ -311,8 +311,8 @@ default(::Type{Union{T, Missing}}) where {T} = default(T)
 default(::Type{Union{T, Nothing}}) where {T} = default(T)
 default(::Type{Union{T, Missing, Nothing}}) where {T} = default(T)
 
-function default(::Type{A}) where {A <: AbstractVector{T}} where {T}
-    a = similar(A, 1)
+function default(::Type{A}) where {A <: AbstractArray{T, N}} where {T, N}
+    a = similar(A, ntuple(one, N))
     a[1] = default(T)
     return a
 end
diff --git a/src/ArrowTypes/test/tests.jl b/src/ArrowTypes/test/tests.jl
index d1e1914..29197c0 100644
--- a/src/ArrowTypes/test/tests.jl
+++ b/src/ArrowTypes/test/tests.jl
@@ -136,6 +136,9 @@ v_nt = (major=1, minor=0, patch=0, prerelease=(), build=())
 @test ArrowTypes.default(Union{Int, Missing}) == Int(0)
 @test ArrowTypes.default(Union{Int, Nothing}) == Int(0)
 @test ArrowTypes.default(Union{Int, Missing, Nothing}) == Int(0)
+@test ArrowTypes.default(Vector{Int}) == zeros(Int, 1)
+@test ArrowTypes.default(Matrix{Int}) == zeros(Int, 1, 1)
+@test ArrowTypes.default(Array{Int,3}) == zeros(Int, 1, 1, 1)
 
 @test ArrowTypes.promoteunion(Int, Float64) == Float64
 @test ArrowTypes.promoteunion(Int, String) == Union{Int, String}