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/05/12 01:12:51 UTC
[superset] 01/01: creat json_metadata field for query object
This is an automated email from the ASF dual-hosted git repository.
hugh pushed a commit to branch add-json-metadata-query
in repository https://gitbox.apache.org/repos/asf/superset.git
commit f3424586411a2904d501636d7e00aa41747f06bf
Author: hughhhh <hu...@gmail.com>
AuthorDate: Wed May 11 21:12:32 2022 -0400
creat json_metadata field for query object
---
.../126264a82d27_add_json_metadata_query_obj.py | 42 ++++++++++++++++++++++
superset/models/sql_lab.py | 1 +
2 files changed, 43 insertions(+)
diff --git a/superset/migrations/versions/126264a82d27_add_json_metadata_query_obj.py b/superset/migrations/versions/126264a82d27_add_json_metadata_query_obj.py
new file mode 100644
index 0000000000..a4427739b4
--- /dev/null
+++ b/superset/migrations/versions/126264a82d27_add_json_metadata_query_obj.py
@@ -0,0 +1,42 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""add_json_metadata_query_obj
+
+Revision ID: 126264a82d27
+Revises: a9422eeaae74
+Create Date: 2022-05-11 21:04:08.101050
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = "126264a82d27"
+down_revision = "a9422eeaae74"
+
+import sqlalchemy as sa
+from alembic import op
+from sqlalchemy.dialects import postgresql
+
+
+def upgrade():
+ op.add_column("query", sa.Column("json_metadata", sa.Text(), nullable=True))
+
+
+def downgrade():
+ try:
+ op.drop_column("query", "json_metadata")
+ except Exception:
+ pass
diff --git a/superset/models/sql_lab.py b/superset/models/sql_lab.py
index 04d5fc9a94..68297093d9 100644
--- a/superset/models/sql_lab.py
+++ b/superset/models/sql_lab.py
@@ -99,6 +99,7 @@ class Query(Model, ExtraJSONMixin):
end_time = Column(Numeric(precision=20, scale=6))
end_result_backend_time = Column(Numeric(precision=20, scale=6))
tracking_url = Column(Text)
+ json_metadata = Column(Text)
changed_on = Column(
DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=True