Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_pandas_dataframe(self, hql, parameters=None):
- if not self.airflow_conn_reqd:
- import pandas
- cursor = self.presto_client.cursor()
- try:
- cursor.execute(self._strip_sql(hql), parameters)
- data = cursor.fetchall()
- except DatabaseError as e:
- raise PrestoException(self._get_pretty_exception_message(e))
- column_descriptions = cursor.description
- if data:
- df = pandas.DataFrame(data)
- df.columns = [c[0] for c in column_descriptions]
- else:
- df = pandas.DataFrame()
- return df
- else:
- return(
- self.get_pandas_df(query)
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement