# Unknown error when using ccall to work with Apache Arrow's GLib interface

**URL:** <https://discourse.julialang.org/t/unknown-error-when-using-ccall-to-work-with-apache-arrows-glib-interface/51794>\
**Category:** Data\
**Created:** [December 14, 2020, 9:14am UTC](https://discourse.julialang.org/t/unknown-error-when-using-ccall-to-work-with-apache-arrows-glib-interface/51794 "2020-12-14T09:14:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![s-kap](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@s-kap](https://discourse.julialang.org/u/s-kap)\
**Post date:** [December 14, 2020, 9:14am UTC](https://discourse.julialang.org/t/unknown-error-when-using-ccall-to-work-with-apache-arrows-glib-interface/51794/1 "2020-12-14T09:14:26Z")

</div>

Hey all,

Context:  
Apache Arrow

- is an in memory columnar format
- has some very speedy IO implementations in c++
- has a C interface using GLib

Since it’s an in-memory format, I’d like to perform IO in cpp, and then convert the resulting c++ Arrow Dataset into an Arrow.jl dataset.

Problem:  
When I run this code, jupyter crashes without too many details

```julia
using Pkg
Pkg.add("Gtk")
using Gtk.GLib
path = "file.parquet"
GError() do error_check
    x = ccall(
        (:gparquet_arrow_file_reader_new_path, "/usr/local/Cellar/apache-arrow-glib/2.0.0/lib/libparquet-glib.200"), 
        GLib.GObject, 
        (AbstractString, Ptr{GError}), 
        path, error_check
    )
end

```

I suspect it has something to do with the Types AbstractString and Ptr{GError} but I’m not sure how to debug. Does anyone have ideas?

It would also be nice if I could code-gen the GLib bindings into Julia. I’ve never done this sort of thing before so I would really appreciate some pointers

---

<div class="post-metadata">

**Author:** ![s-kap](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@s-kap](https://discourse.julialang.org/u/s-kap)\
**Post date:** [December 14, 2020, 11:24am UTC](https://discourse.julialang.org/t/unknown-error-when-using-ccall-to-work-with-apache-arrows-glib-interface/51794/2 "2020-12-14T11:24:16Z")

</div>

On second thought - this fails too:

```julia
GError() do error_check
    println(1)
end

```

with this error message

```julia
MethodError: no method matching !(::Nothing)
Closest candidates are:
  !(!Matched::Missing) at missing.jl:100
  !(!Matched::Bool) at bool.jl:33
  !(!Matched::Function) at operators.jl:896

Stacktrace:
 [1] GError(::var"#3#4")....

```

I don’t really know if there’s a guide to use GLib in Julia but if there is one, I would be happy to read through it

---

<div class="post-metadata">

**Author:** ![jonathanBieler](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)\
**Post date:** [December 14, 2020, 12:45pm UTC](https://discourse.julialang.org/t/unknown-error-when-using-ccall-to-work-with-apache-arrows-glib-interface/51794/3 "2020-12-14T12:45:49Z")

</div>

Looking into Gtk.jl code it seems it’s usually used with a pointer to pointer, which is also what you have in the doc of `gparquet_arrow_file_reader_new_path`.

[https://github.com/JuliaGraphics/Gtk.jl/blob/e243036be95857c5b5c7330fcc0ef91d320d84d3/src/gio.jl#L8](https://github.com/JuliaGraphics/Gtk.jl/blob/e243036be95857c5b5c7330fcc0ef91d320d84d3/src/gio.jl#L8)

As for the string you have to declare it as `Ptr{UInt8}` and convert your string using `Gtk.bytestring` (although I think it does nothing in your case).

[https://github.com/JuliaGraphics/Gtk.jl/blob/7c8802a6fa5ce0002b529d5017ffe72365ea4b4a/src/buttons.jl#L19](https://github.com/JuliaGraphics/Gtk.jl/blob/7c8802a6fa5ce0002b529d5017ffe72365ea4b4a/src/buttons.jl#L19)

---

<div class="post-metadata">

**Author:** ![s-kap](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@s-kap](https://discourse.julialang.org/u/s-kap)\
**Post date:** [December 14, 2020, 10:21pm UTC](https://discourse.julialang.org/t/unknown-error-when-using-ccall-to-work-with-apache-arrows-glib-interface/51794/4 "2020-12-14T22:21:39Z")

</div>

Thank you very much!!  
I’m still seeing an error from `GError() do error_check ...` but I don’t think it’s easy to get around that
