Turn Complex Logic into Simple SQL using Pipelined Table Functions