Skip to content

Commit

Permalink
Set primary column and add tests for recent Parquet2 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
evetion committed Jun 13, 2022
1 parent 1838a59 commit c401614
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Extents = "0.1"
GeoFormatTypes = "0.4.1"
GeoInterface = "1"
JSON3 = "1.9"
Parquet2 = "0.1.7"
Parquet2 = "0.1.9"
StructTypes = "1.8"
Tables = "1"
WellKnownGeometry = "0.1.0"
Expand Down
4 changes: 2 additions & 2 deletions src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ function write(ofn::Union{AbstractString,Parquet2.FilePathsBase.AbstractPath}, d
columns[String(column)] = mc
end

md = Dict("geo" => JSON3.write(GeoParquet.MetaRoot(columns=columns)))
Parquet2.writefile(ofn, df; metadata=md, compression_codec=:zstd, kwargs...)
md = Dict("geo" => JSON3.write(GeoParquet.MetaRoot(columns=columns, primary_column=String(geocolumns[1]))))
Parquet2.writefile(ofn, df, metadata=md, compression_codec=:zstd, kwargs...)
ofn
end

Expand Down
14 changes: 13 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ for url in (
end

@testset "GeoParquet.jl" begin
# Write your tests here.

@testset "Reading" begin
fn = "data/example.parquet"
Expand Down Expand Up @@ -53,4 +52,17 @@ end
df = GeoParquet.read(fn)
GeoParquet.write("data/example_copy.parquet", df, (:geometry,))
end

@testset "Parquet2 FilePath" begin
df = DataFrame(a=UInt16.(1:10), b=Int8.(1:10))
Parquet2.writefile("data/test.parquet", df)
mv("data/test.parquet", "data/test2.parquet", force=true)
ds = Parquet2.Dataset("data/test2.parquet")
df = DataFrame(ds)
@test df.a[1] == 1
@test df.b[end] == 10
@test df.a[1] isa UInt16
@test df.a[1] isa Int8
rm("data/test2.parquet")
end
end

0 comments on commit c401614

Please sign in to comment.