Skip to content

Instantly share code, notes, and snippets.

@t3rmin4t0r
Created June 30, 2015 19:12
Show Gist options
  • Save t3rmin4t0r/7b90f69976e77f09b324 to your computer and use it in GitHub Desktop.
Save t3rmin4t0r/7b90f69976e77f09b324 to your computer and use it in GitHub Desktop.
ATS to Hive query plan extraction
import json
import sys
class ATSFile(object):
def __init__(self, name):
self.data = json.load(open(name))
self.name = name
def dump(self):
info = self.data["otherinfo"]
q = json.loads(info["QUERY"])
txt = q["queryText"]
plan = q["queryPlan"]
open("%s-query.txt" % self.name, "w").write(txt)
json.dump(plan, open("%s-plan.txt" % self.name,"w"), indent=2)
def main(args):
data = [ATSFile(f) for f in args]
for d in data:
d.dump()
if __name__ == "__main__":
main(sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment