From af6160918752753da1bbb26a256a073c318d6aa7 Mon Sep 17 00:00:00 2001 From: rofinn Date: Sat, 20 Feb 2021 21:33:04 -0600 Subject: [PATCH 1/4] Register the Interval structs with Arrow.jl via Requires.jl. --- Project.toml | 6 +++++- src/Intervals.jl | 5 +++++ src/arrow.jl | 6 ++++++ test/arrow.jl | 15 +++++++++++++++ test/runtests.jl | 2 ++ 5 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/arrow.jl create mode 100644 test/arrow.jl diff --git a/Project.toml b/Project.toml index 4b976c86..a475800d 100644 --- a/Project.toml +++ b/Project.toml @@ -8,17 +8,21 @@ version = "1.5.0" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" +Requires = "ae029012-a4dd-5104-9daa-d747884805df" Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b" TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53" [compat] +Arrow = "1" Documenter = "0.23, 0.24" Infinity = "0.2.3" RecipesBase = "0.7, 0.8, 1" +Requires = "1" TimeZones = "0.7, 0.8, 0.9, 0.10, 0.11, 1" julia = "1" [extras] +Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1" Infinity = "a303e19e-6eb4-11e9-3b09-cd9505f79100" @@ -27,4 +31,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" VisualRegressionTests = "34922c18-7c2a-561c-bac1-01e79b2c4c92" [targets] -test = ["Documenter", "ImageMagick", "Infinity", "Plots", "Test", "VisualRegressionTests"] +test = ["Arrow", "Documenter", "ImageMagick", "Infinity", "Plots", "Test", "VisualRegressionTests"] diff --git a/src/Intervals.jl b/src/Intervals.jl index 0c606436..6163c932 100644 --- a/src/Intervals.jl +++ b/src/Intervals.jl @@ -3,6 +3,7 @@ module Intervals using Dates using Printf using RecipesBase +using Requires using Serialization: Serialization, AbstractSerializer, deserialize using TimeZones @@ -35,6 +36,10 @@ include("docstrings.jl") include("deprecated.jl") include("compat.jl") +function __init__() + @require Arrow="69666777-d1a9-59fb-9406-91d4454c9d45" include("arrow.jl") +end + export Bound, Closed, Open, diff --git a/src/arrow.jl b/src/arrow.jl new file mode 100644 index 00000000..770e8226 --- /dev/null +++ b/src/arrow.jl @@ -0,0 +1,6 @@ +# Register our structs with Arrow.jl +Arrow.ArrowTypes.registertype!(Closed, Closed) +Arrow.ArrowTypes.registertype!(Open, Open) +Arrow.ArrowTypes.registertype!(Unbounded, Unbounded) +Arrow.ArrowTypes.registertype!(Interval, Interval) +Arrow.ArrowTypes.registertype!(AnchoredInterval, AnchoredInterval) diff --git a/test/arrow.jl b/test/arrow.jl new file mode 100644 index 00000000..4d88225a --- /dev/null +++ b/test/arrow.jl @@ -0,0 +1,15 @@ +@testset "arrow" begin + zdt_start = ZonedDateTime(2016, 8, 11, 1, tz"America/Winnipeg") + zdt_end = ZonedDateTime(2016, 8, 12, 0, tz"America/Winnipeg") + table = (time = HE.(zdt_start:Hour(1):zdt_end), val = rand(24)) + + # Just test that we can save and load our table type without the time column being + # converted to a NamedTuple + mktempdir() do d + file = joinpath(d, "data.arrow") + Arrow.write(file, table) + loaded = Arrow.Table(file) + @test loaded.time == table.time + @test loaded.val ≈ table.val + end +end diff --git a/test/runtests.jl b/test/runtests.jl index 2c9b64cf..9b91eac4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,3 +1,4 @@ +using Arrow using Base.Iterators: product using Dates using Documenter: doctest @@ -19,6 +20,7 @@ include("test_utils.jl") include("anchoredinterval.jl") include("comparisons.jl") include("plotting.jl") + include("arrow.jl") # Note: The output of the doctests currently requires a newer version of Julia # https://github.com/JuliaLang/julia/pull/34387 From 95d03f1bd1965975015543adb370a0a887f1806c Mon Sep 17 00:00:00 2001 From: rofinn Date: Sun, 21 Feb 2021 13:15:20 -0600 Subject: [PATCH 2/4] Only test on 1.3 or higher. --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 647b9513..6e5f975b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false matrix: version: - - "1.0" # LTS + - "1.3" # Oldest release supported by Arrow.jl - "1" # Latest Release os: - ubuntu-latest From 556662df7e4d4fa8201bb28a3f27df405aff56b3 Mon Sep 17 00:00:00 2001 From: rofinn Date: Mon, 22 Feb 2021 11:51:25 -0600 Subject: [PATCH 3/4] Address review comments. --- test/arrow.jl | 5 +++-- test/runtests.jl | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/test/arrow.jl b/test/arrow.jl index 4d88225a..34cfa46a 100644 --- a/test/arrow.jl +++ b/test/arrow.jl @@ -1,7 +1,7 @@ @testset "arrow" begin zdt_start = ZonedDateTime(2016, 8, 11, 1, tz"America/Winnipeg") zdt_end = ZonedDateTime(2016, 8, 12, 0, tz"America/Winnipeg") - table = (time = HE.(zdt_start:Hour(1):zdt_end), val = rand(24)) + table = (time = HE.(zdt_start:Hour(1):zdt_end), val = collect(1:24)) # Just test that we can save and load our table type without the time column being # converted to a NamedTuple @@ -9,7 +9,8 @@ file = joinpath(d, "data.arrow") Arrow.write(file, table) loaded = Arrow.Table(file) + @test loaded isa Arrow.Table @test loaded.time == table.time - @test loaded.val ≈ table.val + @test loaded.val == table.val end end diff --git a/test/runtests.jl b/test/runtests.jl index 9b91eac4..6f4743ae 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,4 +1,6 @@ -using Arrow +# NOTE: v1.3 checks are for if you want to test on pre-1.3 w/o the Arrow.jl dependency +VERSION > v"1.3" && using Arrow + using Base.Iterators: product using Dates using Documenter: doctest @@ -20,7 +22,7 @@ include("test_utils.jl") include("anchoredinterval.jl") include("comparisons.jl") include("plotting.jl") - include("arrow.jl") + VERSION >= v"1.3" && include("arrow.jl") # Note: The output of the doctests currently requires a newer version of Julia # https://github.com/JuliaLang/julia/pull/34387 From 5280c183d3b6afa68891badb4dde87d2311d776c Mon Sep 17 00:00:00 2001 From: Rory Finnegan Date: Mon, 22 Feb 2021 15:23:47 -0600 Subject: [PATCH 4/4] Update test/runtests.jl Co-authored-by: Curtis Vogt --- test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 6f4743ae..9d159c02 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,5 @@ # NOTE: v1.3 checks are for if you want to test on pre-1.3 w/o the Arrow.jl dependency -VERSION > v"1.3" && using Arrow +VERSION >= v"1.3" && using Arrow using Base.Iterators: product using Dates