Skip to content

Commit c469151

Browse files
Use getproperty instead of type parameter to get names (#415)
Closes #414 `Tables.Schema` does not store names in the type parameters if there are more than `(2^16) - 1` columns: https://github.com/JuliaData/Tables.jl/blob/2cb13998e856692ed273c931b83477caf8b7b020/src/Tables.jl#L477-L483 --------- Co-authored-by: Eric Hanson <[email protected]>
1 parent adf6ab8 commit c469151

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ julia = "1.6"
5353

5454
[extras]
5555
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
56+
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
5657
FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f"
5758
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
5859
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
@@ -61,4 +62,4 @@ TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
6162
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
6263

6364
[targets]
64-
test = ["CategoricalArrays", "FilePathsBase", "JSON3", "Random", "StructTypes", "TOML", "Test"]
65+
test = ["CategoricalArrays", "DataFrames", "FilePathsBase", "JSON3", "Random", "StructTypes", "TOML", "Test"]

src/write.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,9 @@ function makemessage(b, headerType, header, columns=nothing, bodylen=0)
388388
return Message(FlatBuffers.finishedbytes(b), columns, bodylen, headerType == Meta.RecordBatch, headerType == Meta.RecordBatch || headerType == Meta.DictionaryBatch, headerType)
389389
end
390390

391-
function makeschema(b, sch::Tables.Schema{names}, columns) where {names}
391+
function makeschema(b, sch::Tables.Schema, columns)
392392
# build Field objects
393+
names = sch.names
393394
N = length(names)
394395
fieldoffsets = [fieldoffset(b, names[i], columns.cols[i]) for i = 1:N]
395396
Meta.schemaStartFieldsVector(b, N)

test/runtests.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# limitations under the License.
1616

1717
using Test, Arrow, ArrowTypes, Tables, Dates, PooledArrays, TimeZones, UUIDs,
18-
CategoricalArrays, DataAPI, FilePathsBase
18+
CategoricalArrays, DataAPI, FilePathsBase, DataFrames
1919
using Random: randstring
2020

2121
# Compat shim for pre-julia 1.9
@@ -572,6 +572,15 @@ if pkgversion(ArrowTypes) >= v"2.0.2"
572572
@test isequal(a.x, t.x)
573573
end
574574

575+
# https://github.com/apache/arrow-julia/issues/414
576+
df = DataFrame(("$i" => rand(1000) for i in 1:65536)...)
577+
df_load = Arrow.Table(Arrow.tobuffer(df))
578+
@test Tables.schema(df) == Tables.schema(df_load)
579+
for (col1, col2) in zip(Tables.columns(df), Tables.columns(df_load))
580+
@test col1 == col2
581+
end
582+
583+
575584
end # @testset "misc"
576585

577586
end

0 commit comments

Comments
 (0)