tupleReader.setTempTable("scnTable", scnTable);
String rankQuery = "SELECT instance, partition, gen, seq, T1.listIndex AS instanceRank " +
" FROM scnTable JOIN explodeList(`IDEALSTATES/" + TEST_DB + "`) AS T1 " +
"USING (scnTable.instance, T1.listVal) WHERE scnTable.partition=T1.listField";
List<ZNRecord> rankTable = processor.execute(rankQuery, tupleReader);
System.out.println(rankTable.size());
tupleReader.setTempTable("rankTable", rankTable);
String masterSelectionQuery = "SELECT instance, partition, instanceRank, gen, (T.maxSeq-seq) AS seqDiff, seq FROM rankTable JOIN " +
" (SELECT partition, max(to_number(seq)) AS maxSeq FROM rankTable GROUP BY partition) AS T USING(rankTable.partition, T.partition) " +