Created
December 7, 2018 01:00
-
-
Save t3rmin4t0r/dc9ca8678f3717262f459a33db7083b8 to your computer and use it in GitHub Desktop.
ats-extract script - unpack a hive_query ATS entity
This file contains hidden or 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): | |
print self.data.keys() | |
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: | |
try: | |
d.dump() | |
except: | |
pass | |
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