1. A computer implemented method for processing data in a database management system implemented on a network of two or more nodes, each of the two or more nodes comprising a processor, a storage device, and a memory, the method comprising: receiving a query, wherein the query indicates a first user-defined table function, a second user-defined table function, and a table distributed across the two or more nodes, wherein the first user-defined table function and the second user-defined table function together define a user-defined aggregate function applicable to the table and configured to return a result table; and computing a table aggregate in a shared-nothing architecture responsive to the user-defined aggregate function, wherein the table aggregate comprises a resulting table, and wherein the computing the table aggregate comprises: executing the first user-defined table function on each of the two or more nodes by processing respective records of the table residing on each node of the two or more nodes, wherein the processing the respective records comprises generating, at each node of the two or more nodes, a respective data subsample of each record of the table by processing individually each record of the table residing on the node; generating a data sample associated with each node of the two or more nodes as a result of executing the first user-defined table function on each of the two or more nodes, wherein each data sample of the two or more nodes meets sufficiency criteria, and wherein the generating the data sample associated with each node comprises combining, at each node of the two or more nodes, the respective data subsamples of each row of the table residing on the node, wherein the combining is commutative and associative; wherein each data sample meeting the sufficiency criteria is derivable from a single record of the table, wherein each two data samples meeting the sufficiency criteria are combinable via a combination operator to provide an other potential data sample meeting the sufficiency criteria, and wherein the combination operator is commutative and associative; storing the generated data samples in a selected set of nodes; and executing the second user-defined table function on the selected set of nodes by, at each selected node of the selected set of nodes, processing records of the data samples residing on the selected node of the selected set of nodes to generate the table aggregate, wherein the table aggregate comprises a plurality of result values.