Fix the query generator to work with python 2.6.x

Change-Id: Ib7ca870f946d365cb7e026cf753c8f25795dcb06
Reviewed-on: http://gerrit.ent.cloudera.com:8080/3138
Reviewed-by: Ishaan Joshi <ishaan@cloudera.com>
Tested-by: jenkins