villebro commented on a change in pull request #8867: Make schema name for the
CTA queries and limit configurable
URL:
https://github.com/apache/incubator-superset/pull/8867#discussion_r381802479
##########
File path: tests/celery_tests.py
##########
@@ -199,15 +207,92 @@ def drop_table_if_exists(self, table_name,
database=None):
db.session.flush()
return self.run_sql(db_id, sql)
- def test_run_async_query(self):
+ @mock.patch(
+ "superset.views.core.get_cta_schema_name", lambda d, u, s, sql:
CTAS_SCHEMA_NAME
+ )
+ def test_run_sync_query_cta_config(self):
+ main_db = get_example_database()
+ db_id = main_db.id
+ if main_db.backend == "sqlite":
+ # sqlite doesn't support schemas
+ return
+ tmp_table_name = "tmp_async_22"
+ quote =
main_db.get_sqla_engine().dialect.identifier_preparer.quote_identifier
+ expected_full_table_name =
f"{quote(CTAS_SCHEMA_NAME)}.{quote(tmp_table_name)}"
+ self.drop_table_if_exists(expected_full_table_name, main_db)
+ name = "James"
+ sql_where = f"SELECT name FROM birth_names WHERE name='{name}'"
+ result = self.run_sql(
+ db_id, sql_where, "cid2", tmp_table=tmp_table_name, cta=True
+ )
+
+ self.assertEqual(QueryStatus.SUCCESS, result["query"]["state"])
+ self.assertEqual([], result["data"])
+ self.assertEqual([], result["columns"])
+ query = self.get_query_by_id(result["query"]["serverId"])
+ self.assertEqual(
+ f"CREATE TABLE {expected_full_table_name} AS \n"
+ "SELECT name FROM birth_names "
+ "WHERE name='James'",
+ query.executed_sql,
+ )
+ self.assertEqual(
+ "SELECT *\n" f"FROM {expected_full_table_name}", query.select_sql
+ )
+ time.sleep(2)
Review comment:
Not proposing adding unnecessary sleeping, but should we use the regular
`CELERY_SLEEP_TIME` here? Or should we introduce a new `CELERY_SHORT_SLEEP_TIME
= 2` for this?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]