Created
June 30, 2015 19:12
-
-
Save t3rmin4t0r/7b90f69976e77f09b324 to your computer and use it in GitHub Desktop.
ATS to Hive query plan extraction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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