Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[get_df] Adding support for multi-statement SQL" #5078

Merged
merged 5 commits into from
May 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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