# Is this possible to fix "type instability" with IndexedTable operations?

**URL:** https://discourse.julialang.org/t/is-this-possible-to-fix-type-instability-with-indexedtable-operations/32063
**Category:** General Usage
**Created:** [December 9, 2019, 7:25pm UTC](https://discourse.julialang.org/t/is-this-possible-to-fix-type-instability-with-indexedtable-operations/32063 "2019-12-09T19:25:13Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![bashonubuntu](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@bashonubuntu](https://discourse.julialang.org/u/bashonubuntu)
#### Post date: [December 9, 2019, 7:25pm UTC](https://discourse.julialang.org/t/is-this-possible-to-fix-type-instability-with-indexedtable-operations/32063/1 "2019-12-09T19:25:14Z")

</div>

Consider the following code and its `@code_warntype`

```julia
t = table([1,1,2,2], [1,2,1,2], [1,2,3,4], names=[:a,:b,:c], pkey = (:a, :b))
function my_function(t::T) where {T<:IndexedTable}        
 IndexedTables.select(t, IndexedTables.Not(:c))
 return IndexedTables.transform(t, :c => collect(5:8))
end

```

```julia
julia> @code_warntype my_function(t)
Variables
  #self#::Core.Compiler.Const(my_function, false)
  t::IndexedTable{StructArrays.StructArray{NamedTuple{(:a, :b, :c),Tuple{Int64,Int64,Int64}},1,NamedTuple{(:a, :b, :c),Tuple{Array{Int64,1},Array{Int64,1},Array{Int64,1}}},Int64}}

Body::Any
1 ─ %1 = IndexedTables.select::Core.Compiler.Const(IndexedTables.select, false)
│ %2 = IndexedTables.Not::Core.Compiler.Const(IndexedTables.Not, false)
│ %3 = (%2)(:c)::Core.Compiler.Const(IndexedTables.Not{Symbol}(:c), false)
│ (%1)(t, %3)
│ %5 = IndexedTables.transform::Core.Compiler.Const(IndexedTables.transform, false)
│ %6 = (5:8)::Core.Compiler.Const(5:8, false)
│ %7 = Main.collect(%6)::Array{Int64,1}
│ %8 = (:c => %7)::Core.Compiler.PartialStruct(Pair{Symbol,Array{Int64,1}}, Any[Core.Compiler.Const(:c, false), Array{Int64,1}])
│ %9 = (%5)(t, %8)::Any
└── return %9

```

Is the possible to fix such a “type-instability” so that return type is not `Any` but a concrete type? Given that I know the types of each column of the IndexedTable, I was thinking that one should be able to patch this up but maybe I’m misunderstanding and any explanation will be instructive for me. Thanks!
