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

Register the Interval structs with Arrow.jl via Requires.jl #156

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
version:
- "1.0" # LTS
- "1.3" # Oldest release supported by Arrow.jl
rofinn marked this conversation as resolved.
Show resolved Hide resolved
- "1" # Latest Release
os:
- ubuntu-latest
Expand Down
6 changes: 5 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"]
5 changes: 5 additions & 0 deletions src/Intervals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Intervals
using Dates
using Printf
using RecipesBase
using Requires
using Serialization: Serialization, AbstractSerializer, deserialize
using TimeZones

Expand Down Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/arrow.jl
Original file line number Diff line number Diff line change
@@ -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)
16 changes: 16 additions & 0 deletions test/arrow.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@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 = collect(1: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)
rofinn marked this conversation as resolved.
Show resolved Hide resolved
@test loaded isa Arrow.Table
@test loaded.time == table.time
@test loaded.val == table.val
end
end
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 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
Expand All @@ -19,6 +22,7 @@ include("test_utils.jl")
include("anchoredinterval.jl")
include("comparisons.jl")
include("plotting.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
Expand Down