I don't think we can assume that the DataSet returned will be a SimpleDataSet, so we should remove the cast on line 59 and here we should use the iterator() method on DataSet to iterate over each DataSetRow and operate on it.