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/14 21:49:55 UTC

[GitHub] [superset] hughhhh opened a new pull request, #19728: fix: Removetime_range_endpoints from query context object pt 2

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

   <!---
   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 -->
   original reference this time we actually save the data properly 😪
   https://github.com/apache/superset/pull/19423
   
   ### 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] sadpandajoe commented on pull request #19728: fix: Removetime_range_endpoints from query context object pt 2

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

   🏷️  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 commented on a diff in pull request #19728: fix: Removetime_range_endpoints from query context object pt 2

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


##########
superset/migrations/versions/cecc6bf46990_rm_time_range_endpoints_2.py:
##########
@@ -0,0 +1,74 @@
+# 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_2
+
+Revision ID: cecc6bf46990
+Revises: 9d8a8d575284
+Create Date: 2022-04-14 17:21:53.996022
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = "cecc6bf46990"
+down_revision = "9d8a8d575284"
+
+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:
+        pass
+
+    queries = query_context.get("queries")
+
+    for query in queries:
+        query.get("extras", {}).pop("time_range_endpoints", None)
+
+    slc.query_context = json.dumps(query_context)

Review Comment:
   initial we were saving it back to `slc.queries` and that doesn't exist on the Slice model



-- 
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 #19728: fix: Removetime_range_endpoints from query context object pt 2

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


##########
superset/migrations/versions/cecc6bf46990_rm_time_range_endpoints_2.py:
##########
@@ -0,0 +1,74 @@
+# 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_2
+
+Revision ID: cecc6bf46990
+Revises: 9d8a8d575284
+Create Date: 2022-04-14 17:21:53.996022
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = "cecc6bf46990"
+down_revision = "9d8a8d575284"
+
+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:
+        pass
+
+    queries = query_context.get("queries")
+
+    for query in queries:
+        query.get("extras", {}).pop("time_range_endpoints", None)
+
+    slc.query_context = json.dumps(query_context)
+
+
+def upgrade():
+    bind = op.get_bind()
+    session = db.Session(bind=bind)
+    for slc in session.query(Slice).filter(
+        Slice.query_context.like("%time_range_endpoints%")
+    ):
+        upgrade_slice(slc)
+
+    session.commit()

Review Comment:
   it should throw if i'm not mistaken



-- 
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 #19728: fix: Removetime_range_endpoints from query context object pt 2

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


##########
superset/migrations/versions/cecc6bf46990_rm_time_range_endpoints_2.py:
##########
@@ -0,0 +1,74 @@
+# 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_2
+
+Revision ID: cecc6bf46990
+Revises: 9d8a8d575284
+Create Date: 2022-04-14 17:21:53.996022
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = "cecc6bf46990"
+down_revision = "9d8a8d575284"
+
+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:
+        pass

Review Comment:
   You should return here, as the json parse failed



##########
tests/integration_tests/migrations/cecc6bf46990_rm_time_range_endpoints_2__tests.py:
##########
@@ -0,0 +1,92 @@
+# 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.
+import json
+
+from superset.migrations.versions.cecc6bf46990_rm_time_range_endpoints_2 import (
+    Slice,
+    upgrade_slice,
+)
+
+sample_query_context = {
+    "datasource": {"id": 27, "type": "table"},
+    "force": False,
+    "queries": [
+        {
+            "time_range": "No filter",
+            "filters": [],
+            "extras": {
+                "time_grain_sqla": "P1D",
+                "time_range_endpoints": ["inclusive", "exclusive"],
+                "having": "",
+                "having_druid": [],
+                "where": "",
+            },
+            "applied_time_extras": {},
+            "columns": ["a", "b"],
+            "orderby": [],
+            "annotation_layers": [],
+            "row_limit": 1000,
+            "timeseries_limit": 0,
+            "order_desc": True,
+            "url_params": {},
+            "custom_params": {},
+            "custom_form_data": {},
+            "post_processing": [],
+        }
+    ],
+    "form_data": {
+        "viz_type": "table",
+        "datasource": "27__table",
+        "slice_id": 545,
+        "url_params": {},
+        "time_range_endpoints": ["inclusive", "exclusive"],
+        "time_grain_sqla": "P1D",
+        "time_range": "No filter",
+        "query_mode": "raw",
+        "groupby": [],
+        "metrics": [],
+        "all_columns": ["a", "b"],
+        "percent_metrics": [],
+        "adhoc_filters": [],
+        "order_by_cols": [],
+        "row_limit": 1000,
+        "server_page_length": 10,
+        "include_time": False,
+        "order_desc": True,
+        "table_timestamp_format": "smart_date",
+        "show_cell_bars": True,
+        "color_pn": True,
+        "extra_form_data": {},
+        "force": False,
+        "result_format": "json",
+        "result_type": "full",
+    },
+    "result_format": "json",
+    "result_type": "full",
+}
+
+
+def test_upgrade():

Review Comment:
   Can you add a test for the case when the query_context is non-json?



-- 
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 #19728: fix: Removetime_range_endpoints from query context object pt 2

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


-- 
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 #19728: fix: Removetime_range_endpoints from query context object pt 2

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

   # [Codecov](https://codecov.io/gh/apache/superset/pull/19728?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 [#19728](https://codecov.io/gh/apache/superset/pull/19728?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (3610305) into [master](https://codecov.io/gh/apache/superset/commit/94075983f8abfcc7749cede5af9e24d2a9f1abe0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (9407598) will **decrease** coverage by `12.84%`.
   > The diff coverage is `n/a`.
   
   > :exclamation: Current head 3610305 differs from pull request most recent head 7d74a30. Consider uploading reports for the commit 7d74a30 to get more accurate results
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #19728       +/-   ##
   ===========================================
   - Coverage   66.51%   53.66%   -12.85%     
   ===========================================
     Files        1686     1686               
     Lines       64591    64591               
     Branches     6636     6636               
   ===========================================
   - Hits        42961    34663     -8298     
   - Misses      19931    28229     +8298     
     Partials     1699     1699               
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | hive | `?` | |
   | mysql | `?` | |
   | postgres | `?` | |
   | presto | `52.54% <ø> (ø)` | |
   | python | `56.25% <ø> (-26.19%)` | :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/19728?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/dashboard\_import\_export.py](https://codecov.io/gh/apache/superset/pull/19728/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/key\_value/commands/upsert.py](https://codecov.io/gh/apache/superset/pull/19728/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: |
   | [superset/key\_value/commands/update.py](https://codecov.io/gh/apache/superset/pull/19728/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-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL3VwZGF0ZS5weQ==) | `0.00% <0.00%> (-89.37%)` | :arrow_down: |
   | [superset/key\_value/commands/delete.py](https://codecov.io/gh/apache/superset/pull/19728/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-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL2RlbGV0ZS5weQ==) | `0.00% <0.00%> (-85.30%)` | :arrow_down: |
   | [superset/db\_engines/hive.py](https://codecov.io/gh/apache/superset/pull/19728/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) | `0.00% <0.00%> (-85.19%)` | :arrow_down: |
   | [superset/key\_value/commands/delete\_expired.py](https://codecov.io/gh/apache/superset/pull/19728/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-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL2RlbGV0ZV9leHBpcmVkLnB5) | `0.00% <0.00%> (-80.77%)` | :arrow_down: |
   | [superset/dashboards/commands/importers/v0.py](https://codecov.io/gh/apache/superset/pull/19728/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-c3VwZXJzZXQvZGFzaGJvYXJkcy9jb21tYW5kcy9pbXBvcnRlcnMvdjAucHk=) | `14.79% <0.00%> (-75.15%)` | :arrow_down: |
   | [superset/datasets/commands/importers/v0.py](https://codecov.io/gh/apache/superset/pull/19728/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-c3VwZXJzZXQvZGF0YXNldHMvY29tbWFuZHMvaW1wb3J0ZXJzL3YwLnB5) | `24.82% <0.00%> (-68.80%)` | :arrow_down: |
   | [superset/databases/commands/test\_connection.py](https://codecov.io/gh/apache/superset/pull/19728/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-c3VwZXJzZXQvZGF0YWJhc2VzL2NvbW1hbmRzL3Rlc3RfY29ubmVjdGlvbi5weQ==) | `31.42% <0.00%> (-68.58%)` | :arrow_down: |
   | [superset/datasets/commands/update.py](https://codecov.io/gh/apache/superset/pull/19728/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-c3VwZXJzZXQvZGF0YXNldHMvY29tbWFuZHMvdXBkYXRlLnB5) | `25.88% <0.00%> (-68.24%)` | :arrow_down: |
   | ... and [268 more](https://codecov.io/gh/apache/superset/pull/19728/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/19728?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/19728?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 [9407598...7d74a30](https://codecov.io/gh/apache/superset/pull/19728?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] eschutho commented on a diff in pull request #19728: fix: Removetime_range_endpoints from query context object pt 2

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


##########
tests/integration_tests/migrations/cecc6bf46990_rm_time_range_endpoints_2__tests.py:
##########
@@ -0,0 +1,92 @@
+# 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.
+import json
+
+from superset.migrations.versions.cecc6bf46990_rm_time_range_endpoints_2 import (
+    Slice,
+    upgrade_slice,
+)
+
+sample_query_context = {
+    "datasource": {"id": 27, "type": "table"},
+    "force": False,
+    "queries": [
+        {
+            "time_range": "No filter",
+            "filters": [],
+            "extras": {
+                "time_grain_sqla": "P1D",
+                "time_range_endpoints": ["inclusive", "exclusive"],
+                "having": "",
+                "having_druid": [],
+                "where": "",
+            },
+            "applied_time_extras": {},
+            "columns": ["a", "b"],
+            "orderby": [],
+            "annotation_layers": [],
+            "row_limit": 1000,
+            "timeseries_limit": 0,
+            "order_desc": True,
+            "url_params": {},
+            "custom_params": {},
+            "custom_form_data": {},
+            "post_processing": [],
+        }
+    ],
+    "form_data": {
+        "viz_type": "table",
+        "datasource": "27__table",
+        "slice_id": 545,
+        "url_params": {},
+        "time_range_endpoints": ["inclusive", "exclusive"],
+        "time_grain_sqla": "P1D",
+        "time_range": "No filter",
+        "query_mode": "raw",
+        "groupby": [],
+        "metrics": [],
+        "all_columns": ["a", "b"],
+        "percent_metrics": [],
+        "adhoc_filters": [],
+        "order_by_cols": [],
+        "row_limit": 1000,
+        "server_page_length": 10,
+        "include_time": False,
+        "order_desc": True,
+        "table_timestamp_format": "smart_date",
+        "show_cell_bars": True,
+        "color_pn": True,
+        "extra_form_data": {},
+        "force": False,
+        "result_format": "json",
+        "result_type": "full",
+    },
+    "result_format": "json",
+    "result_type": "full",
+}
+
+
+def test_upgrade():
+    slc = Slice(slice_name="FOO", query_context=json.dumps(sample_query_context))
+
+    upgrade_slice(slc)
+
+    query_context = json.loads(slc.query_context)
+    queries = query_context.get("queries")
+    for q in queries:
+        extras = q.get("extras", {})
+        assert "time_range_endpoints" not in extras

Review Comment:
   nice! A test on a migration!



-- 
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 a diff in pull request #19728: fix: Removetime_range_endpoints from query context object pt 2

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


##########
superset/migrations/versions/cecc6bf46990_rm_time_range_endpoints_2.py:
##########
@@ -0,0 +1,74 @@
+# 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_2
+
+Revision ID: cecc6bf46990
+Revises: 9d8a8d575284
+Create Date: 2022-04-14 17:21:53.996022
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = "cecc6bf46990"
+down_revision = "9d8a8d575284"
+
+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:
+        pass
+
+    queries = query_context.get("queries")
+
+    for query in queries:
+        query.get("extras", {}).pop("time_range_endpoints", None)
+
+    slc.query_context = json.dumps(query_context)
+
+
+def upgrade():
+    bind = op.get_bind()
+    session = db.Session(bind=bind)
+    for slc in session.query(Slice).filter(
+        Slice.query_context.like("%time_range_endpoints%")
+    ):
+        upgrade_slice(slc)
+
+    session.commit()

Review Comment:
   do we log anything if this doesn't work or if there are errors?



-- 
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 a diff in pull request #19728: fix: Removetime_range_endpoints from query context object pt 2

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


##########
superset/migrations/versions/cecc6bf46990_rm_time_range_endpoints_2.py:
##########
@@ -0,0 +1,74 @@
+# 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_2
+
+Revision ID: cecc6bf46990
+Revises: 9d8a8d575284
+Create Date: 2022-04-14 17:21:53.996022
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = "cecc6bf46990"
+down_revision = "9d8a8d575284"
+
+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:
+        pass
+
+    queries = query_context.get("queries")
+
+    for query in queries:
+        query.get("extras", {}).pop("time_range_endpoints", None)
+
+    slc.query_context = json.dumps(query_context)
+
+
+def upgrade():
+    bind = op.get_bind()
+    session = db.Session(bind=bind)
+    for slc in session.query(Slice).filter(
+        Slice.query_context.like("%time_range_endpoints%")
+    ):
+        upgrade_slice(slc)
+
+    session.commit()

Review Comment:
   do we log anything if this doesn't work?



-- 
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 a diff in pull request #19728: fix: Removetime_range_endpoints from query context object pt 2

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


##########
tests/integration_tests/migrations/cecc6bf46990_rm_time_range_endpoints_2__tests.py:
##########
@@ -0,0 +1,92 @@
+# 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.
+import json
+
+from superset.migrations.versions.cecc6bf46990_rm_time_range_endpoints_2 import (
+    Slice,
+    upgrade_slice,
+)
+
+sample_query_context = {
+    "datasource": {"id": 27, "type": "table"},
+    "force": False,
+    "queries": [
+        {
+            "time_range": "No filter",
+            "filters": [],
+            "extras": {
+                "time_grain_sqla": "P1D",
+                "time_range_endpoints": ["inclusive", "exclusive"],
+                "having": "",
+                "having_druid": [],
+                "where": "",
+            },
+            "applied_time_extras": {},
+            "columns": ["a", "b"],
+            "orderby": [],
+            "annotation_layers": [],
+            "row_limit": 1000,
+            "timeseries_limit": 0,
+            "order_desc": True,
+            "url_params": {},
+            "custom_params": {},
+            "custom_form_data": {},
+            "post_processing": [],
+        }
+    ],
+    "form_data": {
+        "viz_type": "table",
+        "datasource": "27__table",
+        "slice_id": 545,
+        "url_params": {},
+        "time_range_endpoints": ["inclusive", "exclusive"],

Review Comment:
   total nit, but technically this wouldn't be on this payload.



-- 
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 a diff in pull request #19728: fix: Removetime_range_endpoints from query context object pt 2

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


##########
superset/migrations/versions/cecc6bf46990_rm_time_range_endpoints_2.py:
##########
@@ -0,0 +1,74 @@
+# 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_2
+
+Revision ID: cecc6bf46990
+Revises: 9d8a8d575284
+Create Date: 2022-04-14 17:21:53.996022
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = "cecc6bf46990"
+down_revision = "9d8a8d575284"
+
+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:
+        pass
+
+    queries = query_context.get("queries")
+
+    for query in queries:
+        query.get("extras", {}).pop("time_range_endpoints", None)
+
+    slc.query_context = json.dumps(query_context)

Review Comment:
   good catch! 



-- 
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] ktmud commented on pull request #19728: fix: Removetime_range_endpoints from query context object pt 2

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

   maybe not necessary, but id the original migration doesn't work, maybe we can change it to noop?


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