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/04/18 18:38:27 UTC

[GitHub] [superset] hughhhh opened a new pull request, #19767: fix: Fix migration for removing time_range_endpoints 3

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

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   Update on #19728 to also remove `time_range_endpoints` from `form_data` payload as well.
   
   ### 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
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] 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] hughhhh commented on pull request #19767: fix: Fix migration for removing time_range_endpoints 3

Posted by GitBox <gi...@apache.org>.
hughhhh commented on PR #19767:
URL: https://github.com/apache/superset/pull/19767#issuecomment-1102231382

   Verifed locally that this migration works:
   ```
   >> select count(*) from slices where query_context like '%time_range_endpoints%'
   5
   
   >> superset db upgrade
   INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
   INFO  [alembic.runtime.migration] Will assume transactional DDL.
   INFO  [alembic.runtime.migration] Running upgrade cecc6bf46990 -> ad07e4fdbaba, rm_time_range_endpoints_from_qc_3
   slices updated with no time_range_endpoints: 5
   
   >> select count(*) from slices where query_context like '%time_range_endpoints%'
   0
   ```


-- 
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] sadpandajoe commented on pull request #19767: fix: Fix migration for removing time_range_endpoints 3

Posted by GitBox <gi...@apache.org>.
sadpandajoe commented on PR #19767:
URL: https://github.com/apache/superset/pull/19767#issuecomment-1102912892

   🏷️  preset:2022.15


-- 
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] hughhhh merged pull request #19767: fix: Fix migration for removing time_range_endpoints 3

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


-- 
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] eschutho commented on pull request #19767: fix: Fix migration for removing time_range_endpoints 3

Posted by GitBox <gi...@apache.org>.
eschutho commented on PR #19767:
URL: https://github.com/apache/superset/pull/19767#issuecomment-1101661214

   do you want to make cecc6bf46990 a noop again?


-- 
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 #19767: fix: Fix migration for removing time_range_endpoints 3

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

   # [Codecov](https://codecov.io/gh/apache/superset/pull/19767?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 [#19767](https://codecov.io/gh/apache/superset/pull/19767?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (32844f7) into [master](https://codecov.io/gh/apache/superset/commit/cf5145918ba6da3b8b803bed86ad7ca22d50494a?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (cf51459) will **decrease** coverage by `17.00%`.
   > The diff coverage is `n/a`.
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #19767       +/-   ##
   ===========================================
   - Coverage   66.51%   49.50%   -17.01%     
   ===========================================
     Files        1687     1687               
     Lines       64618    64618               
     Branches     6646     6646               
   ===========================================
   - Hits        42978    31991    -10987     
   - Misses      19940    30927    +10987     
     Partials     1700     1700               
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | hive | `?` | |
   | mysql | `?` | |
   | postgres | `?` | |
   | presto | `?` | |
   | python | `47.75% <ø> (-34.68%)` | :arrow_down: |
   | sqlite | `?` | |
   | unit | `47.75% <ø> (ø)` | |
   
   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/19767?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/examples/css\_templates.py](https://codecov.io/gh/apache/superset/pull/19767/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-c3VwZXJzZXQvZXhhbXBsZXMvY3NzX3RlbXBsYXRlcy5weQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [superset/reports/notifications/email.py](https://codecov.io/gh/apache/superset/pull/19767/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-c3VwZXJzZXQvcmVwb3J0cy9ub3RpZmljYXRpb25zL2VtYWlsLnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [superset/utils/dashboard\_import\_export.py](https://codecov.io/gh/apache/superset/pull/19767/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-c3VwZXJzZXQvdXRpbHMvZGFzaGJvYXJkX2ltcG9ydF9leHBvcnQucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [superset/reports/notifications/exceptions.py](https://codecov.io/gh/apache/superset/pull/19767/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-c3VwZXJzZXQvcmVwb3J0cy9ub3RpZmljYXRpb25zL2V4Y2VwdGlvbnMucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [superset/reports/commands/alert.py](https://codecov.io/gh/apache/superset/pull/19767/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-c3VwZXJzZXQvcmVwb3J0cy9jb21tYW5kcy9hbGVydC5weQ==) | `0.00% <0.00%> (-96.52%)` | :arrow_down: |
   | [superset/common/query\_context\_factory.py](https://codecov.io/gh/apache/superset/pull/19767/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-c3VwZXJzZXQvY29tbW9uL3F1ZXJ5X2NvbnRleHRfZmFjdG9yeS5weQ==) | `0.00% <0.00%> (-96.43%)` | :arrow_down: |
   | [superset/reports/notifications/base.py](https://codecov.io/gh/apache/superset/pull/19767/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-c3VwZXJzZXQvcmVwb3J0cy9ub3RpZmljYXRpb25zL2Jhc2UucHk=) | `0.00% <0.00%> (-95.84%)` | :arrow_down: |
   | [superset/cli/test.py](https://codecov.io/gh/apache/superset/pull/19767/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-c3VwZXJzZXQvY2xpL3Rlc3QucHk=) | `0.00% <0.00%> (-93.94%)` | :arrow_down: |
   | [superset/reports/commands/execute.py](https://codecov.io/gh/apache/superset/pull/19767/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-c3VwZXJzZXQvcmVwb3J0cy9jb21tYW5kcy9leGVjdXRlLnB5) | `0.00% <0.00%> (-91.52%)` | :arrow_down: |
   | [superset/key\_value/commands/upsert.py](https://codecov.io/gh/apache/superset/pull/19767/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-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL3Vwc2VydC5weQ==) | `0.00% <0.00%> (-89.59%)` | :arrow_down: |
   | ... and [294 more](https://codecov.io/gh/apache/superset/pull/19767/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/superset/pull/19767?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/superset/pull/19767?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [cf51459...32844f7](https://codecov.io/gh/apache/superset/pull/19767?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?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] hughhhh commented on a diff in pull request #19767: fix: Fix migration for removing time_range_endpoints 3

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


##########
superset/migrations/versions/ad07e4fdbaba_rm_time_range_endpoints_from_qc_3.py:
##########
@@ -0,0 +1,83 @@
+# 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.
+"""rm_time_range_endpoints_from_qc_3
+
+Revision ID: ad07e4fdbaba
+Revises: cecc6bf46990
+Create Date: 2022-04-18 11:20:47.390901
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = "ad07e4fdbaba"
+down_revision = "cecc6bf46990"
+
+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 Slice(Base):
+    __tablename__ = "slices"
+    id = sa.Column(sa.Integer, primary_key=True)
+    query_context = sa.Column(sa.Text)
+    slice_name = sa.Column(sa.String(250))
+
+
+def upgrade_slice(slc: Slice):
+    try:
+        query_context = json.loads(slc.query_context)
+    except json.decoder.JSONDecodeError:
+        return
+
+    queries = query_context.get("queries")
+    query_context.get("form_data", {}).pop("time_range_endpoints", None)
+    for query in queries:
+        query.get("extras", {}).pop("time_range_endpoints", None)
+
+    slc.query_context = json.dumps(query_context)
+
+    return slc
+
+
+def upgrade():
+    bind = op.get_bind()
+    session = db.Session(bind=bind)
+    slices_updated = 0
+    for slc in (
+        session.query(Slice)
+        .filter(Slice.query_context.like("%time_range_endpoints%"))
+        .all()
+    ):
+        updated_slice = upgrade_slice(slc)
+        if updated_slice:
+            session.merge(slc)
+            slices_updated += 1
+
+    print(f"slices updated with no time_range_endpoints: {slices_updated}")

Review Comment:
   logger.info wasn't properly printing when the running the upgrade



-- 
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] craig-rueda commented on a diff in pull request #19767: fix: Fix migration for removing time_range_endpoints 3

Posted by GitBox <gi...@apache.org>.
craig-rueda commented on code in PR #19767:
URL: https://github.com/apache/superset/pull/19767#discussion_r853038604


##########
superset/migrations/versions/ad07e4fdbaba_rm_time_range_endpoints_from_qc_3.py:
##########
@@ -0,0 +1,83 @@
+# 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.
+"""rm_time_range_endpoints_from_qc_3
+
+Revision ID: ad07e4fdbaba
+Revises: cecc6bf46990
+Create Date: 2022-04-18 11:20:47.390901
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = "ad07e4fdbaba"
+down_revision = "cecc6bf46990"
+
+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 Slice(Base):
+    __tablename__ = "slices"
+    id = sa.Column(sa.Integer, primary_key=True)
+    query_context = sa.Column(sa.Text)
+    slice_name = sa.Column(sa.String(250))
+
+
+def upgrade_slice(slc: Slice):
+    try:
+        query_context = json.loads(slc.query_context)
+    except json.decoder.JSONDecodeError:
+        return
+
+    queries = query_context.get("queries")
+    query_context.get("form_data", {}).pop("time_range_endpoints", None)
+    for query in queries:
+        query.get("extras", {}).pop("time_range_endpoints", None)
+
+    slc.query_context = json.dumps(query_context)
+
+    return slc
+
+
+def upgrade():
+    bind = op.get_bind()
+    session = db.Session(bind=bind)
+    slices_updated = 0
+    for slc in (
+        session.query(Slice)
+        .filter(Slice.query_context.like("%time_range_endpoints%"))
+        .all()
+    ):
+        updated_slice = upgrade_slice(slc)
+        if updated_slice:
+            session.merge(slc)
+            slices_updated += 1
+
+    print(f"slices updated with no time_range_endpoints: {slices_updated}")

Review Comment:
   What if the update_slice method only returns a value if it actually finds the json key it's looking for? Then the log message would be accurate. 



##########
superset/migrations/versions/ad07e4fdbaba_rm_time_range_endpoints_from_qc_3.py:
##########
@@ -0,0 +1,83 @@
+# 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.
+"""rm_time_range_endpoints_from_qc_3
+
+Revision ID: ad07e4fdbaba
+Revises: cecc6bf46990
+Create Date: 2022-04-18 11:20:47.390901
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = "ad07e4fdbaba"
+down_revision = "cecc6bf46990"
+
+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 Slice(Base):
+    __tablename__ = "slices"
+    id = sa.Column(sa.Integer, primary_key=True)
+    query_context = sa.Column(sa.Text)
+    slice_name = sa.Column(sa.String(250))
+
+
+def upgrade_slice(slc: Slice):
+    try:
+        query_context = json.loads(slc.query_context)
+    except json.decoder.JSONDecodeError:
+        return
+
+    queries = query_context.get("queries")
+    query_context.get("form_data", {}).pop("time_range_endpoints", None)
+    for query in queries:
+        query.get("extras", {}).pop("time_range_endpoints", None)
+
+    slc.query_context = json.dumps(query_context)
+
+    return slc
+
+
+def upgrade():
+    bind = op.get_bind()
+    session = db.Session(bind=bind)
+    slices_updated = 0
+    for slc in (
+        session.query(Slice)
+        .filter(Slice.query_context.like("%time_range_endpoints%"))
+        .all()
+    ):
+        updated_slice = upgrade_slice(slc)
+        if updated_slice:
+            session.merge(slc)
+            slices_updated += 1
+
+    print(f"slices updated with no time_range_endpoints: {slices_updated}")

Review Comment:
   Please use logger.info instead of print. 



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