Skip to content

Instantly share code, notes, and snippets.

@t3rmin4t0r
Created November 7, 2014 00:50
Show Gist options
  • Save t3rmin4t0r/51262d1346094b6b5f7f to your computer and use it in GitHub Desktop.
Save t3rmin4t0r/51262d1346094b6b5f7f to your computer and use it in GitHub Desktop.
Hive Serialization.ddl to Create Table helper
import sys
for l in sys.stdin:
l = l.strip()
name = l[0:l.find("{")]
cols = [x.strip().split(" ") for x in l[l.find("{")+1:l.find("}")].split(",")]
print "create table ", name, "(",
print ",".join(["%s %s" % (b,a) for (a,b) in cols]), ");"
[gopal@cn041-10 comcast]$
@t3rmin4t0r
Copy link
Author

grep --text serialization.ddl orig_plan.txt | sort | sed "s/ *//" | uniq | python ddl.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment