You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by hu...@apache.org on 2022/10/03 23:02:14 UTC

[superset] branch fix-cpq-get-col updated: add get_column function for Query obj

This is an automated email from the ASF dual-hosted git repository.

hugh pushed a commit to branch fix-cpq-get-col
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/fix-cpq-get-col by this push:
     new 3c9b6d5a08 add get_column function for Query obj
3c9b6d5a08 is described below

commit 3c9b6d5a08d490161bb31a5328b93ddaa030dfc2
Author: hughhhh <hu...@gmail.com>
AuthorDate: Mon Oct 3 19:01:34 2022 -0400

    add get_column function for Query obj
---
 superset/models/sql_lab.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/superset/models/sql_lab.py b/superset/models/sql_lab.py
index 408bc708df..eb8957070c 100644
--- a/superset/models/sql_lab.py
+++ b/superset/models/sql_lab.py
@@ -332,6 +332,14 @@ class Query(
     def tracking_url(self, value: str) -> None:
         self.tracking_url_raw = value
 
+    def get_column(self, column_name: Optional[str]) -> Optional["BaseColumn"]:
+        if not column_name:
+            return None
+        for col in self.columns:
+            if col.column_name == column_name:
+                return col
+        return None
+
 
 class SavedQuery(Model, AuditMixinNullable, ExtraJSONMixin, ImportExportMixin):
     """ORM model for SQL query"""