Skip to content

Commit

Permalink
Revert "[get_df] Adding support for multi-statement SQL (#5060)"
Browse files Browse the repository at this point in the history
This reverts commit 17d6464.
  • Loading branch information
john-bodley authored May 24, 2018
1 parent 2d8bd63 commit c6cd461
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
8 changes: 2 additions & 6 deletions superset/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,13 +690,9 @@ def get_quoter(self):
return self.get_dialect().identifier_preparer.quote

def get_df(self, sql, schema):
sqls = [x.strip() for x in sql.strip().strip(';').split(';')]
sql = sql.strip().strip(';')
eng = self.get_sqla_engine(schema=schema)

for i in range(len(sqls) - 1):
eng.execute(sqls[i])

df = pd.read_sql_query(sqls[-1], eng)
df = pd.read_sql_query(sql, eng)

def needs_conversion(df_series):
if df_series.empty:
Expand Down
14 changes: 0 additions & 14 deletions tests/model_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,6 @@ def test_grains_dict(self):
self.assertEquals(d.get('P1D').function, 'DATE({col})')
self.assertEquals(d.get('Time Column').function, '{col}')

def test_single_statement(self):
main_db = self.get_main_database(db.session)

if main_db.backend == 'mysql':
df = main_db.get_df('SELECT 1', None)
self.assertEquals(df.iat[0, 0], 1)

def test_multi_statement(self):
main_db = self.get_main_database(db.session)

if main_db.backend == 'mysql':
df = main_db.get_df('USE superset; SELECT 1', None)
self.assertEquals(df.iat[0, 0], 1)


class SqlaTableModelTestCase(SupersetTestCase):

Expand Down

0 comments on commit c6cd461

Please sign in to comment.