Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. def get_pandas_dataframe(self, hql, parameters=None):
  2. if not self.airflow_conn_reqd:
  3. import pandas
  4. cursor = self.presto_client.cursor()
  5. try:
  6. cursor.execute(self._strip_sql(hql), parameters)
  7. data = cursor.fetchall()
  8. except DatabaseError as e:
  9. raise PrestoException(self._get_pretty_exception_message(e))
  10. column_descriptions = cursor.description
  11. if data:
  12. df = pandas.DataFrame(data)
  13. df.columns = [c[0] for c in column_descriptions]
  14. else:
  15. df = pandas.DataFrame()
  16. return df
  17. else:
  18. return(
  19. self.get_pandas_df(query)
  20. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement