outputFinalRow()

The outputFinalRow() method is called only when the table function is invoked using the "table with final" syntax.

select * from table with final(tablefunction(arg1,...))

The purpose of the outputFinalRow() method is for a UDTF to output rows after all of the input to the table function has been processed. This processRow() method can be used to store all of the data in a Lua table. The outputFinalRow() method can then be used to perform a calculation on the data and output the final result for the table function.

The outputFinalRow() method behaves very similarly to the outputRow() method. Just as with outputRow(), outputFinalRow() is passed a single argument on each call that is the number of times the outputFinalRow() function has been called. This makes it easier for the developer to know what data should be returned on each call.
function outputFinalRow(rownum)
if rownum > 1 then return null end
return { result1, result2, result3 }
end