# Why does JET.jl has a problem with adding a column to a dataframe?

**URL:** https://discourse.julialang.org/t/why-does-jet-jl-has-a-problem-with-adding-a-column-to-a-dataframe/88490
**Category:** General Usage
**Tags:** question
**Created:** [October 9, 2022, 4:35pm UTC](https://discourse.julialang.org/t/why-does-jet-jl-has-a-problem-with-adding-a-column-to-a-dataframe/88490 "2022-10-09T16:35:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Soldalma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/soldalma/32/29388_2.png) [@Soldalma](https://discourse.julialang.org/u/Soldalma)
#### Post date: [October 9, 2022, 4:35pm UTC](https://discourse.julialang.org/t/why-does-jet-jl-has-a-problem-with-adding-a-column-to-a-dataframe/88490/1 "2022-10-09T16:35:53Z")

</div>

I started using JET.jl recently. In most cases it is helpful. However, sometimes I just cannot figure out why it has a problem with my code. An example is below. The function `foo` is very basic and works fine. Still, JET.jl’s macto @report\_call reports an error. What is happening?

```julia
(@v1.8) pkg> activate --temp
  Activating new project at `C:\Users\fsald\AppData\Local\Temp\jl_774bEc`

(jl_774bEc) pkg> add DataFrames JET
# Info omitted here

using DataFrames, JET
df = DataFrame(:A => [1.0, 2.0, 3.0, 4.0])
# 4×1 DataFrame
# Row │ A       
# │ Float64
# ─────┼─────────
# 1 │ 1.0
# 2 │ 2.0
# 3 │ 3.0
# 4 │ 4.0

function foo(df::DataFrame)::DataFrame
    v = 1:nrow(df)
    df[!, :B] = v

    return df
end
# foo (generic function with 1 method)

foo(df)
# 4×2 DataFrame
# Row │ A B     
# │ Float64 Int64
# ─────┼────────────────
# 1 │ 1.0 1
# 2 │ 2.0 2
# 3 │ 3.0 3
# 4 │ 4.0 4

@report_call foo(df)
# ═════ 1 possible error found ═════
# ┌ @ REPL[15]:3 df[!, :B] = v
# │┌ @ C:\Users\fsald\.julia\packages\DataFrames\Lrd7K\src\dataframe\dataframe.jl:669 DataFrames.insert_single_column!(df, v, col_ind)
# ││┌ @ C:\Users\fsald\.julia\packages\DataFrames\Lrd7K\src\dataframe\dataframe.jl:653 DataFrames._drop_all_nonnote_metadata!(df)
# │││┌ @ C:\Users\fsald\.julia\packages\DataFrames\Lrd7K\src\other\metadata.jl:759 DataFrames._drop_table_nonnote_metadata!(df)
# ││││┌ @ C:\Users\fsald\.julia\packages\DataFrames\Lrd7K\src\other\metadata.jl:752 = iterate(metadatakeys(df), getfield(_3, 2))
# │││││┌ @ tuple.jl:68 t[i]
# ││││││┌ @ tuple.jl:29 Base.getfield(t, i, $(Expr(:boundscheck)))
# │││││││ invalid builtin function call

```

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [October 9, 2022, 4:46pm UTC](https://discourse.julialang.org/t/why-does-jet-jl-has-a-problem-with-adding-a-column-to-a-dataframe/88490/2 "2022-10-09T16:46:14Z")

</div>

you can’t not tell us what is `foo`…

---

<div class="post-metadata">

### Author: ![Soldalma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/soldalma/32/29388_2.png) [@Soldalma](https://discourse.julialang.org/u/Soldalma)
#### Post date: [October 9, 2022, 5:54pm UTC](https://discourse.julialang.org/t/why-does-jet-jl-has-a-problem-with-adding-a-column-to-a-dataframe/88490/3 "2022-10-09T17:54:56Z")

</div>

Sorry, I skipped it while cutting and pasting. The edited question now has a definition for `foo`.
