I need to migrate a certain table using databricks notebooks. Problem is databricks SQL doesn't support the implementation of cursors.
What alternative could I use?
This is roughly what I need to do, for reference:
`
Declare @GrupoReg as varchar(10)
Declare @DescReg as varchar(50)
Declare @OrdenReg as varchar(10)
Declare RegistroGpo cursor for
select distinct group, groupdesc, grouporder
from #table1
order by gruouporder
Open RegisterGpo
fetch next from RegistroGpo into @GrupoReg, @DescReg, @OrdenReg
while (@@fetch_status=0)
begin
update #b set groupconcentrado = case when groupconcentrado = '' then @GrupoReg else groupconcentrado + ',' + @GrupoReg end,
groupconcentradodesc = case when groupconcentradodesc = '' then @DescReg else groupconcentradodesc + ',' + @DescReg end,
groupconcentradoorder = case when groupconcentradoorder = '' then @OrdenReg else groupconcentradoorder + @OrdenReg end
from #table2 a
join #table1 b on a.suc = b.suc and a.cli = b.cli and b.group = @GrupoReg
fetch next from RegisterGpo into @GrupoReg, @DescReg, @OrdenReg
end
`
Any help is appreciated
My knowledge of databricks sql and scala is pretty barebones. I don't really know what to try