Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup testing #462

Merged
merged 2 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,10 @@ CodecZstd = "0.7"
ConcurrentUtilities = "2"
DataAPI = "1"
EnumX = "1"
FilePathsBase = "0.9"
LoggingExtras = "0.4, 1"
PooledArrays = "0.5, 1.0"
SentinelArrays = "1"
Tables = "1.1"
TimeZones = "1"
TranscodingStreams = "0.9.12"
julia = "1.6"

[extras]
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["CategoricalArrays", "DataFrames", "FilePathsBase", "JSON3", "Random", "StructTypes", "TOML", "Test", "Sockets"]
9 changes: 0 additions & 9 deletions src/ArrowTypes/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,3 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
julia = "1.0"

[extras]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[targets]
test = ["Test", "Random", "Sockets", "UUIDs"]
21 changes: 21 additions & 0 deletions src/ArrowTypes/test/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

[deps]
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
47 changes: 47 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

[deps]
ArrowTypes = "31f734f8-188a-4ce0-8406-c8a06bd891cd"
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
PooledArrays = "2dfb63ee-cc39-5dd5-95bd-886bf059d720"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
SentinelArrays = "91c51154-3ec4-41a3-a24f-3f23e20d615c"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
ArrowTypes = "2.2.2"
CategoricalArrays = "0.10"
DataAPI = "1"
DataFrames = "1"
FilePathsBase = "0.9"
JSON3 = "1"
PooledArrays = "1"
StructTypes = "1"
SentinelArrays = "1"
Tables = "1"
TimeZones = "1"
8 changes: 5 additions & 3 deletions test/pyarrow_roundtrip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ include(joinpath(dirname(pathof(Arrow)), "../test/testtables.jl"))

for (nm, t, writekw, readkw, extratests) in testtables
nm == "unions" && continue
println("pyarrow roundtrip: $nm")
@testset "pyarrow roundtrip: $nm" begin
io = IOBuffer()
Arrow.write(io, t; writekw...)
seekstart(io)
Expand All @@ -36,7 +36,8 @@ for (nm, t, writekw, readkw, extratests) in testtables
buf = sink.getvalue()
jbytes = copy(reinterpret(UInt8, buf))
tt = Arrow.Table(jbytes)
println("pyarrow roundtrip w/ compression: $nm")
end
@testset "pyarrow roundtrip w/ compression: $nm" begin
io = IOBuffer()
Arrow.write(io, t; compress=((:lz4, :zstd)[rand(1:2)]), writekw...)
seekstart(io)
Expand All @@ -51,6 +52,7 @@ for (nm, t, writekw, readkw, extratests) in testtables
buf = sink.getvalue()
jbytes = copy(reinterpret(UInt8, buf))
tt = Arrow.Table(jbytes)
end
end

f1 = pa.field("f1", pa.float64(), true)
Expand All @@ -71,4 +73,4 @@ writer.write_batch(batch)
writer.close()
buf = sink.getvalue()
jbytes = copy(reinterpret(UInt8, buf))
tt = Arrow.Table(jbytes)
tt = Arrow.Table(jbytes)
59 changes: 28 additions & 31 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.

using Test, Arrow, ArrowTypes, Tables, Dates, PooledArrays, TimeZones, UUIDs, Sockets,
CategoricalArrays, DataAPI, FilePathsBase, DataFrames
using Random: randstring

# Compat shim for pre-julia 1.9
if !@isdefined(pkgversion)
baumgold marked this conversation as resolved.
Show resolved Hide resolved
using TOML
function pkgversion(m::Module)
toml = TOML.parsefile(joinpath(pkgdir(m), "Project.toml"))
return VersionNumber(toml["version"])
end
end
using Test
using Arrow
using ArrowTypes
using Tables
using Dates
using PooledArrays
using TimeZones
using UUIDs
using Sockets
using CategoricalArrays
using DataAPI
using FilePathsBase
using DataFrames
import Random: randstring

include(joinpath(dirname(pathof(ArrowTypes)), "../test/tests.jl"))
include(joinpath(dirname(pathof(Arrow)), "../test/testtables.jl"))
Expand Down Expand Up @@ -72,11 +74,12 @@ end # @testset "table append"

for file in readdir(joinpath(dirname(pathof(Arrow)), "../test/arrowjson"))
jsonfile = joinpath(joinpath(dirname(pathof(Arrow)), "../test/arrowjson"), file)
println("integration test for $jsonfile")
@testset "integration test for $jsonfile" begin
df = ArrowJSON.parsefile(jsonfile);
io = Arrow.tobuffer(df)
tbl = Arrow.Table(io; convert=false);
@test isequal(df, tbl)
end
end

end # @testset "arrow json integration tests"
Expand Down Expand Up @@ -605,21 +608,15 @@ table = Arrow.Table(joinpath(@__DIR__, "old_zdt.arrow"))
end

@testset "# 243" begin
if pkgversion(ArrowTypes) >= v"2.0.1" # need the ArrowTypes bugfix to pass this test
# https://github.com/apache/arrow-julia/issues/243
table = (; col = [(; v=v"1"), (; v=v"2"), missing])
@test isequal(Arrow.Table(Arrow.tobuffer(table)).col, table.col)
end
table = (; col = [(; v=v"1"), (; v=v"2"), missing])
@test isequal(Arrow.Table(Arrow.tobuffer(table)).col, table.col)
end

@testset "# 367" begin
# https://github.com/apache/arrow-julia/issues/367
if pkgversion(ArrowTypes) >= v"2.0.2"
t = (; x=Union{ZonedDateTime,Missing}[missing])
a = Arrow.Table(Arrow.tobuffer(t))
@test Tables.schema(a) == Tables.schema(t)
@test isequal(a.x, t.x)
end
t = (; x=Union{ZonedDateTime,Missing}[missing])
a = Arrow.Table(Arrow.tobuffer(t))
@test Tables.schema(a) == Tables.schema(t)
@test isequal(a.x, t.x)
end

# https://github.com/apache/arrow-julia/issues/414
Expand Down Expand Up @@ -707,14 +704,14 @@ t = Arrow.Table(buf)

end

# @testset "# 456" begin
@testset "# 456" begin

# NT = @NamedTuple{x::Int, y::Union{Missing,Int}}
# data = NT[(x=1,y=2), (x=2,y=missing), (x=3,y=4), (x=4,y=5)]
# t = [(a=1,b=view(data,1:2)), (a=2,b=view(data,3:4)), missing]
# @test Arrow.toarrowvector(t) isa Arrow.Struct
NT = @NamedTuple{x::Int, y::Union{Missing,Int}}
data = NT[(x=1,y=2), (x=2,y=missing), (x=3,y=4), (x=4,y=5)]
t = [(a=1,b=view(data,1:2)), (a=2,b=view(data,3:4)), missing]
@test Arrow.toarrowvector(t) isa Arrow.Struct

# end
end

end # @testset "misc"

Expand Down
3 changes: 2 additions & 1 deletion test/testappend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

function testappend(nm, t, writekw, readkw, extratests)
println("testing append: $nm")
@testset "append: $nm" begin
io = Arrow.tobuffer(t; writekw...)
bytes = read(io)
mktemp() do path, io
Expand All @@ -33,6 +33,7 @@ function testappend(nm, t, writekw, readkw, extratests)
end
@test nparts == 2
end
end
end

function testappend_compression(compression_option)
Expand Down
4 changes: 2 additions & 2 deletions test/testtables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ testtables = [
];

function testtable(nm, t, writekw, readkw, extratests)
println("testing: $nm")
@testset "testing: $nm" begin
io = Arrow.tobuffer(t; writekw...)
tt = Arrow.Table(io; readkw...)
@test length(tt) == length(t)
Expand Down Expand Up @@ -253,5 +253,5 @@ function testtable(nm, t, writekw, readkw, extratests)
tt = first(str)
@test length(tt) == length(t)
@test all(isequal.(values(t), values(tt)))
return
end
end