You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/06/22 09:30:15 UTC

[GitHub] [incubator-superset] villebro commented on a change in pull request #9794: feat: implement create view as functionality in Sqllab

villebro commented on a change in pull request #9794:
URL: https://github.com/apache/incubator-superset/pull/9794#discussion_r443427139



##########
File path: superset/sql_parse.py
##########
@@ -31,6 +32,11 @@
 logger = logging.getLogger(__name__)
 
 
+class CtaMethod(str, Enum):

Review comment:
       nit: I'd prefer `CtasMethod`

##########
File path: tests/celery_tests.py
##########
@@ -132,34 +134,52 @@ def run_sql(
                 select_as_cta=cta,
                 tmp_table_name=tmp_table,
                 client_id=client_id,
+                cta_method=cta_method,
             ),
         )
         self.logout()
         return json.loads(resp.data)
 
-    def test_run_sync_query_dont_exist(self):
+    @parameterized.expand(
+        [CtaMethod.TABLE,]
+    )
+    def test_run_sync_query_dont_exist(self, cta_method):
         main_db = get_example_database()
         db_id = main_db.id
         sql_dont_exist = "SELECT name FROM table_dont_exist"
-        result1 = self.run_sql(db_id, sql_dont_exist, "1", cta=True)
-        self.assertTrue("error" in result1)
+        result = self.run_sql(
+            db_id, sql_dont_exist, f"1_{cta_method}", cta=True, cta_method=cta_method
+        )
+        if get_example_database().backend != "sqlite" and cta_method == CtaMethod.VIEW:
+            self.assertEqual(QueryStatus.SUCCESS, result["status"], msg=result)
+        else:
+            self.assertEqual(QueryStatus.FAILED, result["status"], msg=result)
 
-    def test_run_sync_query_cta(self):
+    @parameterized.expand([CtaMethod.TABLE, CtaMethod.VIEW])

Review comment:
       This pattern could really help clean up many of our tests 👍 

##########
File path: superset/models/sql_lab.py
##########
@@ -72,6 +72,7 @@ class Query(Model, ExtraJSONMixin):
     limit = Column(Integer)
     select_as_cta = Column(Boolean)
     select_as_cta_used = Column(Boolean, default=False)
+    cta_method = Column(String(16), default=CtaMethod.TABLE)

Review comment:
       nit: `ctas_method`




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org