You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "hughhhh (via GitHub)" <gi...@apache.org> on 2023/05/03 21:09:25 UTC
[GitHub] [superset] hughhhh opened a new pull request, #23925: fix(migration): add log for values unseen in `Slice.datasource_type`
hughhhh opened a new pull request, #23925:
URL: https://github.com/apache/superset/pull/23925
<!---
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 -->
### 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] eschutho commented on a diff in pull request #23925: fix(migration): add log for values unseen in `Slice.datasource_type`
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #23925:
URL: https://github.com/apache/superset/pull/23925#discussion_r1184324986
##########
superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py:
##########
@@ -48,13 +51,16 @@ class Slice(Base): # type: ignore
def upgrade_slc(slc: Slice) -> None:
# clean up all charts with datasource_type not != table
slc.datasource_type = "table"
+ ds_id = None
+ ds_type = None
try:
params_dict = json.loads(slc.params)
ds_id, ds_type = params_dict["datasource"].split("__")
params_dict["datasource"] = f"{ds_id}__table"
slc.params = json.dumps(params_dict)
Review Comment:
```suggestion
slc.params = json.dumps(params_dict)
logger.warning("updated query from %s__%s to a dataset", ds_id, ds_type)
```
--
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 #23925: fix(migration): add log for values unseen in `Slice.datasource_type`
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #23925:
URL: https://github.com/apache/superset/pull/23925#discussion_r1184303428
##########
superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py:
##########
@@ -63,9 +66,15 @@ def upgrade():
session = db.Session(bind=bind)
with op.batch_alter_table("slices") as batch_op:
- for slc in session.query(Slice).filter(Slice.datasource_type == "query").all():
- upgrade_slc(slc)
- session.add(slc)
+ for slc in session.query(Slice).filter(Slice.datasource_type != "table").all():
+ if slc.datasource_type == "query":
+ upgrade_slc(slc)
+ session.add(slc)
+
+ else:
+ logger.warn(
+ f"unknown value detected for slc.datasource_type: {slc.datasource_type}"
Review Comment:
I would suggest also putting a log into line 60 above in case that's where the failure is.
--
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 #23925: fix(migration): add log for values unseen in `Slice.datasource_type`
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #23925:
URL: https://github.com/apache/superset/pull/23925#discussion_r1184360952
##########
superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py:
##########
@@ -48,13 +51,29 @@ class Slice(Base): # type: ignore
def upgrade_slc(slc: Slice) -> None:
# clean up all charts with datasource_type not != table
slc.datasource_type = "table"
+ ds_id = None
+ ds_type = None
try:
params_dict = json.loads(slc.params)
ds_id, ds_type = params_dict["datasource"].split("__")
+ # the assumption here is that the query was saved as a dataset
+ # but the type wasn't written properly to the slice
+ # by updating the type here we expect it will either work
+ # or it will 404 when the dataset is looked up.
params_dict["datasource"] = f"{ds_id}__table"
slc.params = json.dumps(params_dict)
+ logger.warning(
+ "updated slice datasource from %s__%s to %s__table", ds_id, ds_type, ds_id
Review Comment:
```suggestion
"updated slice datasource from %s__%s to %s__table for slice: %s", ds_id, ds_type, ds_id, slc.id
```
--
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 #23925: fix(migration): add log for values unseen in `Slice.datasource_type`
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on PR #23925:
URL: https://github.com/apache/superset/pull/23925#issuecomment-1533777601
@hughhhh don't we need to create a new dataset from the query? Rather than just changing the datasource_type to table?
--
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 #23925: fix(migration): add log for values unseen in `Slice.datasource_type`
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #23925:
URL: https://github.com/apache/superset/pull/23925#discussion_r1184322714
##########
superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py:
##########
@@ -48,13 +51,16 @@ class Slice(Base): # type: ignore
def upgrade_slc(slc: Slice) -> None:
# clean up all charts with datasource_type not != table
slc.datasource_type = "table"
+ ds_id = None
+ ds_type = None
try:
params_dict = json.loads(slc.params)
ds_id, ds_type = params_dict["datasource"].split("__")
Review Comment:
```suggestion
ds_id, ds_type = params_dict["datasource"].split("__")
# the assumption here is that the query was saved as a dataset
# but the type wasn't written properly to the slice
# by updating the type here we expect it will either work
# or it will 404 when the dataset is looked up.
```
--
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 #23925: fix(migration): add log for values unseen in `Slice.datasource_type`
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #23925:
URL: https://github.com/apache/superset/pull/23925#issuecomment-1533765590
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/23925?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 [#23925](https://app.codecov.io/gh/apache/superset/pull/23925?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (dfb4fd2) into [master](https://app.codecov.io/gh/apache/superset/commit/ad19cd9fbd1dd91f27b6871dff0e95453c3c97c7?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (ad19cd9) will **decrease** coverage by `11.39%`.
> The diff coverage is `n/a`.
> :exclamation: Current head dfb4fd2 differs from pull request most recent head bc251cf. Consider uploading reports for the commit bc251cf to get more accurate results
```diff
@@ Coverage Diff @@
## master #23925 +/- ##
===========================================
- Coverage 68.10% 56.72% -11.39%
===========================================
Files 1941 1941
Lines 75020 75020
Branches 8155 8155
===========================================
- Hits 51096 42552 -8544
- Misses 21841 30385 +8544
Partials 2083 2083
```
| Flag | Coverage Δ | |
|---|---|---|
| hive | `?` | |
| mysql | `?` | |
| postgres | `?` | |
| sqlite | `?` | |
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.
[see 307 files with indirect coverage changes](https://app.codecov.io/gh/apache/superset/pull/23925/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
: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] hughhhh commented on a diff in pull request #23925: fix(migration): add log for values unseen in `Slice.datasource_type`
Posted by "hughhhh (via GitHub)" <gi...@apache.org>.
hughhhh commented on code in PR #23925:
URL: https://github.com/apache/superset/pull/23925#discussion_r1184304838
##########
superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py:
##########
@@ -63,9 +66,15 @@ def upgrade():
session = db.Session(bind=bind)
with op.batch_alter_table("slices") as batch_op:
- for slc in session.query(Slice).filter(Slice.datasource_type == "query").all():
- upgrade_slc(slc)
- session.add(slc)
+ for slc in session.query(Slice).filter(Slice.datasource_type != "table").all():
+ if slc.datasource_type == "query":
+ upgrade_slc(slc)
+ session.add(slc)
+
+ else:
+ logger.warn(
+ f"unknown value detected for slc.datasource_type: {slc.datasource_type}"
Review Comment:
so that's only going to be updating slices that are "query", i updated the session.query to look at all instances that are != table
Just wanted to make a path to log information but still update bad slices that have datasource_type = query
--
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 #23925: fix(migration): add log for values unseen in `Slice.datasource_type`
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #23925:
URL: https://github.com/apache/superset/pull/23925#discussion_r1184324986
##########
superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py:
##########
@@ -48,13 +51,16 @@ class Slice(Base): # type: ignore
def upgrade_slc(slc: Slice) -> None:
# clean up all charts with datasource_type not != table
slc.datasource_type = "table"
+ ds_id = None
+ ds_type = None
try:
params_dict = json.loads(slc.params)
ds_id, ds_type = params_dict["datasource"].split("__")
params_dict["datasource"] = f"{ds_id}__table"
slc.params = json.dumps(params_dict)
Review Comment:
```suggestion
slc.params = json.dumps(params_dict)
logger.warning("updated query from %s__%s to a dataset/sqlatable", ds_id, ds_type)
```
--
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 #23925: fix(migration): add log for values unseen in `Slice.datasource_type`
Posted by "hughhhh (via GitHub)" <gi...@apache.org>.
hughhhh commented on code in PR #23925:
URL: https://github.com/apache/superset/pull/23925#discussion_r1184304838
##########
superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py:
##########
@@ -63,9 +66,15 @@ def upgrade():
session = db.Session(bind=bind)
with op.batch_alter_table("slices") as batch_op:
- for slc in session.query(Slice).filter(Slice.datasource_type == "query").all():
- upgrade_slc(slc)
- session.add(slc)
+ for slc in session.query(Slice).filter(Slice.datasource_type != "table").all():
+ if slc.datasource_type == "query":
+ upgrade_slc(slc)
+ session.add(slc)
+
+ else:
+ logger.warn(
+ f"unknown value detected for slc.datasource_type: {slc.datasource_type}"
Review Comment:
so that's only going to be updating slices that are "query", i updated the session.query to look at all instances that are != table
--
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 #23925: fix(migration): add log for values unseen in `Slice.datasource_type`
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #23925:
URL: https://github.com/apache/superset/pull/23925#discussion_r1184324986
##########
superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py:
##########
@@ -48,13 +51,16 @@ class Slice(Base): # type: ignore
def upgrade_slc(slc: Slice) -> None:
# clean up all charts with datasource_type not != table
slc.datasource_type = "table"
+ ds_id = None
+ ds_type = None
try:
params_dict = json.loads(slc.params)
ds_id, ds_type = params_dict["datasource"].split("__")
params_dict["datasource"] = f"{ds_id}__table"
slc.params = json.dumps(params_dict)
Review Comment:
```suggestion
slc.params = json.dumps(params_dict)
logger.warning("updated slice datasource_type from from %s__%s to a dataset/table", ds_id, ds_type)
```
##########
superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py:
##########
@@ -48,13 +51,16 @@ class Slice(Base): # type: ignore
def upgrade_slc(slc: Slice) -> None:
# clean up all charts with datasource_type not != table
slc.datasource_type = "table"
+ ds_id = None
+ ds_type = None
try:
params_dict = json.loads(slc.params)
ds_id, ds_type = params_dict["datasource"].split("__")
params_dict["datasource"] = f"{ds_id}__table"
slc.params = json.dumps(params_dict)
Review Comment:
```suggestion
slc.params = json.dumps(params_dict)
logger.warning("updated slice datasource_type from from %s__%s to table", ds_id, ds_type)
```
--
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 #23925: fix(migration): add log for values unseen in `Slice.datasource_type`
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on PR #23925:
URL: https://github.com/apache/superset/pull/23925#issuecomment-1534991572
🏷️ preset:2023.17
--
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 #23925: fix(migration): add log for values unseen in `Slice.datasource_type`
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #23925:
URL: https://github.com/apache/superset/pull/23925#discussion_r1184324986
##########
superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py:
##########
@@ -48,13 +51,16 @@ class Slice(Base): # type: ignore
def upgrade_slc(slc: Slice) -> None:
# clean up all charts with datasource_type not != table
slc.datasource_type = "table"
+ ds_id = None
+ ds_type = None
try:
params_dict = json.loads(slc.params)
ds_id, ds_type = params_dict["datasource"].split("__")
params_dict["datasource"] = f"{ds_id}__table"
slc.params = json.dumps(params_dict)
Review Comment:
```suggestion
slc.params = json.dumps(params_dict)
logger.warning("updated slice datasource_type from %s__%s to table", ds_id, ds_type)
```
--
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 #23925: fix(migration): add log for values unseen in `Slice.datasource_type`
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #23925:
URL: https://github.com/apache/superset/pull/23925#discussion_r1184324986
##########
superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py:
##########
@@ -48,13 +51,16 @@ class Slice(Base): # type: ignore
def upgrade_slc(slc: Slice) -> None:
# clean up all charts with datasource_type not != table
slc.datasource_type = "table"
+ ds_id = None
+ ds_type = None
try:
params_dict = json.loads(slc.params)
ds_id, ds_type = params_dict["datasource"].split("__")
params_dict["datasource"] = f"{ds_id}__table"
slc.params = json.dumps(params_dict)
Review Comment:
```suggestion
slc.params = json.dumps(params_dict)
logger.warning("updated query from %s__%s to a dataset/table", ds_id, ds_type)
```
--
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 #23925: fix(migration): add log for values unseen in `Slice.datasource_type`
Posted by "craig-rueda (via GitHub)" <gi...@apache.org>.
craig-rueda commented on code in PR #23925:
URL: https://github.com/apache/superset/pull/23925#discussion_r1184297045
##########
superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py:
##########
@@ -63,9 +66,15 @@ def upgrade():
session = db.Session(bind=bind)
with op.batch_alter_table("slices") as batch_op:
- for slc in session.query(Slice).filter(Slice.datasource_type == "query").all():
- upgrade_slc(slc)
- session.add(slc)
+ for slc in session.query(Slice).filter(Slice.datasource_type != "table").all():
+ if slc.datasource_type == "query":
+ upgrade_slc(slc)
+ session.add(slc)
+
+ else:
+ logger.info(
Review Comment:
`logger.warn()`
--
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 #23925: fix(migration): add log for values unseen in `Slice.datasource_type`
Posted by "hughhhh (via GitHub)" <gi...@apache.org>.
hughhhh merged PR #23925:
URL: https://github.com/apache/superset/pull/23925
--
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 #23925: fix(migration): add log for values unseen in `Slice.datasource_type`
Posted by "craig-rueda (via GitHub)" <gi...@apache.org>.
craig-rueda commented on code in PR #23925:
URL: https://github.com/apache/superset/pull/23925#discussion_r1184296805
##########
superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py:
##########
@@ -36,6 +37,8 @@
Base = declarative_base()
+logger = logging.getLogger()
Review Comment:
`logging.getLogger(__name__)`
--
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 #23925: fix(migration): add log for values unseen in `Slice.datasource_type`
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #23925:
URL: https://github.com/apache/superset/pull/23925#discussion_r1184360952
##########
superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py:
##########
@@ -48,13 +51,29 @@ class Slice(Base): # type: ignore
def upgrade_slc(slc: Slice) -> None:
# clean up all charts with datasource_type not != table
slc.datasource_type = "table"
+ ds_id = None
+ ds_type = None
try:
params_dict = json.loads(slc.params)
ds_id, ds_type = params_dict["datasource"].split("__")
+ # the assumption here is that the query was saved as a dataset
+ # but the type wasn't written properly to the slice
+ # by updating the type here we expect it will either work
+ # or it will 404 when the dataset is looked up.
params_dict["datasource"] = f"{ds_id}__table"
slc.params = json.dumps(params_dict)
+ logger.warning(
+ "updated slice datasource from %s__%s to %s__table", ds_id, ds_type, ds_id
Review Comment:
```suggestion
"updated slice datasource from %s__%s to %s__table for slice: %s",
ds_id,
ds_type,
ds_id,
slc.id
```
--
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 #23925: fix(migration): add log for values unseen in `Slice.datasource_type`
Posted by "craig-rueda (via GitHub)" <gi...@apache.org>.
craig-rueda commented on code in PR #23925:
URL: https://github.com/apache/superset/pull/23925#discussion_r1184288057
##########
superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py:
##########
@@ -63,9 +63,15 @@ def upgrade():
session = db.Session(bind=bind)
with op.batch_alter_table("slices") as batch_op:
- for slc in session.query(Slice).filter(Slice.datasource_type == "query").all():
- upgrade_slc(slc)
- session.add(slc)
+ for slc in session.query(Slice).filter(Slice.datasource_type != "table").all():
+ if slc.datasource_type == "query":
+ upgrade_slc(slc)
+ session.add(slc)
+
+ else:
+ print(
Review Comment:
Can we use a logger here? Print is a little nasty for aggregators like Datadog :P
--
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 #23925: fix(migration): add log for values unseen in `Slice.datasource_type`
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #23925:
URL: https://github.com/apache/superset/pull/23925#discussion_r1184324986
##########
superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py:
##########
@@ -48,13 +51,16 @@ class Slice(Base): # type: ignore
def upgrade_slc(slc: Slice) -> None:
# clean up all charts with datasource_type not != table
slc.datasource_type = "table"
+ ds_id = None
+ ds_type = None
try:
params_dict = json.loads(slc.params)
ds_id, ds_type = params_dict["datasource"].split("__")
params_dict["datasource"] = f"{ds_id}__table"
slc.params = json.dumps(params_dict)
Review Comment:
```suggestion
slc.params = json.dumps(params_dict)
logger.warning("updated slice datasource from %s__%s to %s__table", ds_id, ds_type, ds_id)
```
--
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