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 2022/11/28 18:44:42 UTC

[GitHub] [superset] kgabryje opened a new pull request, #22248: chore: Add a migration that removes filter_bar_orientation from dashboard's json_metadata

kgabryje opened a new pull request, #22248:
URL: https://github.com/apache/superset/pull/22248

   
   ### SUMMARY
   This PR adds a downgrade migration that removes `filter_bar_orientation` field from dashboard's `json_metadata`.
   It's related to the horizontal filter bar feature that's currently in development and is locked behind a `HORIZONTAL_FILTER_BAR` feature flag.
   It's a required cleanup step when downgrading Superset version, because the horizontal filter bar project adds `filter_bar_orientation` field to `DashboardJSONMetadataSchema` schema.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [x] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [x] Migration is atomic, supports rollback & is backwards-compatible
     - [x] Confirm DB migration upgrade and downgrade tested
     - [x] Runtime estimates and downtime expectations provided
     `
       Current: 0.26 s 
       10+: 0.40 s
       100+: 0.41 s
       1000+: 0.25 s
   `
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

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


[GitHub] [superset] kgabryje merged pull request #22248: chore: Add a migration that removes filter_bar_orientation from dashboard's json_metadata

Posted by GitBox <gi...@apache.org>.
kgabryje merged PR #22248:
URL: https://github.com/apache/superset/pull/22248


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

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


[GitHub] [superset] kgabryje commented on a diff in pull request #22248: chore: Add a migration that removes filter_bar_orientation from dashboard's json_metadata

Posted by GitBox <gi...@apache.org>.
kgabryje commented on code in PR #22248:
URL: https://github.com/apache/superset/pull/22248#discussion_r1034580012


##########
superset/migrations/versions/2022-11-28_17-51_4ce1d9b25135_remove_filter_bar_orientation.py:
##########
@@ -0,0 +1,67 @@
+# 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.
+"""remove_filter_bar_orientation
+
+Revision ID: 4ce1d9b25135
+Revises: deb4c9d4a4ef
+Create Date: 2022-11-28 17:51:08.954439
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = "4ce1d9b25135"
+down_revision = "deb4c9d4a4ef"
+
+import json
+
+import sqlalchemy as sa
+from alembic import op
+from sqlalchemy.ext.declarative import declarative_base
+
+from superset import db
+
+Base = declarative_base()
+
+
+class Dashboard(Base):
+    __tablename__ = "dashboards"
+    id = sa.Column(sa.Integer, primary_key=True)
+    json_metadata = sa.Column(sa.Text)
+
+
+def upgrade():
+    pass
+
+
+def downgrade():
+    bind = op.get_bind()
+    session = db.Session(bind=bind)
+
+    dashboards = (
+        session.query(Dashboard)
+        .filter(Dashboard.json_metadata.like('%"filter_bar_orientation"%'))
+        .all()
+    )
+    for dashboard in dashboards:
+        try:
+            json_meta = json.loads(dashboard.json_metadata)
+            json_meta.pop("filter_bar_orientation", None)
+            dashboard.json_metadata = json.dumps(json_meta)

Review Comment:
   Good point, didn't think of that 😄 



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

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


[GitHub] [superset] codecov[bot] commented on pull request #22248: chore: Add a migration that removes filter_bar_orientation from dashboard's json_metadata

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #22248:
URL: https://github.com/apache/superset/pull/22248#issuecomment-1329590984

   # [Codecov](https://codecov.io/gh/apache/superset/pull/22248?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#22248](https://codecov.io/gh/apache/superset/pull/22248?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e99fce2) into [master](https://codecov.io/gh/apache/superset/commit/435926b89e08395f3017a32ea00f3de252fd4fb7?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (435926b) will **increase** coverage by `0.16%`.
   > The diff coverage is `n/a`.
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #22248      +/-   ##
   ==========================================
   + Coverage   55.46%   55.63%   +0.16%     
   ==========================================
     Files        1841     1841              
     Lines       70220    70220              
     Branches     7670     7670              
   ==========================================
   + Hits        38947    39066     +119     
   + Misses      29291    29172     -119     
     Partials     1982     1982              
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | hive | `52.56% <ø> (?)` | |
   | presto | `52.45% <ø> (ø)` | |
   | python | `57.80% <ø> (+0.35%)` | :arrow_up: |
   | unit | `50.87% <ø> (ø)` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/22248?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [superset/utils/core.py](https://codecov.io/gh/apache/superset/pull/22248/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdXRpbHMvY29yZS5weQ==) | `64.20% <0.00%> (+0.10%)` | :arrow_up: |
   | [superset/connectors/sqla/models.py](https://codecov.io/gh/apache/superset/pull/22248/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvY29ubmVjdG9ycy9zcWxhL21vZGVscy5weQ==) | `75.14% <0.00%> (+0.39%)` | :arrow_up: |
   | [superset/db\_engine\_specs/base.py](https://codecov.io/gh/apache/superset/pull/22248/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGJfZW5naW5lX3NwZWNzL2Jhc2UucHk=) | `75.78% <0.00%> (+1.25%)` | :arrow_up: |
   | [superset/result\_set.py](https://codecov.io/gh/apache/superset/pull/22248/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvcmVzdWx0X3NldC5weQ==) | `79.71% <0.00%> (+2.17%)` | :arrow_up: |
   | [superset/connectors/sqla/utils.py](https://codecov.io/gh/apache/superset/pull/22248/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvY29ubmVjdG9ycy9zcWxhL3V0aWxzLnB5) | `80.58% <0.00%> (+2.91%)` | :arrow_up: |
   | [superset/db\_engine\_specs/hive.py](https://codecov.io/gh/apache/superset/pull/22248/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGJfZW5naW5lX3NwZWNzL2hpdmUucHk=) | `64.82% <0.00%> (+30.43%)` | :arrow_up: |
   | [superset/db\_engines/hive.py](https://codecov.io/gh/apache/superset/pull/22248/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGJfZW5naW5lcy9oaXZlLnB5) | `85.18% <0.00%> (+85.18%)` | :arrow_up: |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

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


[GitHub] [superset] villebro commented on a diff in pull request #22248: chore: Add a migration that removes filter_bar_orientation from dashboard's json_metadata

Posted by GitBox <gi...@apache.org>.
villebro commented on code in PR #22248:
URL: https://github.com/apache/superset/pull/22248#discussion_r1034547165


##########
superset/migrations/versions/2022-11-28_17-51_4ce1d9b25135_remove_filter_bar_orientation.py:
##########
@@ -0,0 +1,67 @@
+# 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.
+"""remove_filter_bar_orientation
+
+Revision ID: 4ce1d9b25135
+Revises: deb4c9d4a4ef
+Create Date: 2022-11-28 17:51:08.954439
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = "4ce1d9b25135"
+down_revision = "deb4c9d4a4ef"
+
+import json
+
+import sqlalchemy as sa
+from alembic import op
+from sqlalchemy.ext.declarative import declarative_base
+
+from superset import db
+
+Base = declarative_base()
+
+
+class Dashboard(Base):
+    __tablename__ = "dashboards"
+    id = sa.Column(sa.Integer, primary_key=True)
+    json_metadata = sa.Column(sa.Text)
+
+
+def upgrade():
+    pass
+
+
+def downgrade():
+    bind = op.get_bind()
+    session = db.Session(bind=bind)
+
+    dashboards = (
+        session.query(Dashboard)
+        .filter(Dashboard.json_metadata.like('%"filter_bar_orientation"%'))
+        .all()
+    )
+    for dashboard in dashboards:
+        try:
+            json_meta = json.loads(dashboard.json_metadata)
+            json_meta.pop("filter_bar_orientation", None)
+            dashboard.json_metadata = json.dumps(json_meta)

Review Comment:
   nit: To avoid unnecessarily updating the metadata if someone *happens* to have the text `filter_bar_orientation` in one of the titles, descriptions or similar (highly likely 😄), maybe add this as a precaution:
   ```suggestion
               filter_bar_orientation = json_meta.pop("filter_bar_orientation", None)
               if filter_bar_orientation:
                   dashboard.json_metadata = json.dumps(json_meta)
   ```



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

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