Skip to content

Instantly share code, notes, and snippets.

@mayhem
Created September 4, 2019 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mayhem/98389b65eb8d2bfff3de96053751d28b to your computer and use it in GitHub Desktop.
Save mayhem/98389b65eb8d2bfff3de96053751d28b to your computer and use it in GitHub Desktop.
## utils.py
def register_dataframe(df, table_name):
try:
df.createOrReplaceTempView(table_name)
except HolyShitTableNotFoundException as err:
df.createOrReplaceTempView(alternate_table_name)
try:
utils.register_dataframe(df, table)
except Py4JJavaError as err:
logging.error('{}\n{}\nAborting...'.format(str(err), err.java_exception))
sys.exit(-1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment