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/07/20 03:14:32 UTC

[GitHub] [superset] zhaoyongjie opened a new pull request, #20780: fix: unexpected commit causes pytest failure

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

   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   The latest SQLAlchemy [upgrade](https://github.com/apache/superset/pull/19890) seems to be changing the autoflush rule. It causes `test_fetch_metadata_for_updated_virtual_table` failure.
   
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   Pure backend changes, so no screenshot.
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   should pass following command in local and passes CI.
   ```
   pytest --disable-warnings -s tests/integration_tests/sqla_models_tests.py -k test_fetch_metadata_for_updated_virtual_table
   ```
   
   
   ### 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] codecov[bot] commented on pull request #20780: fix: unexpected commit causes pytest failure

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

   # [Codecov](https://codecov.io/gh/apache/superset/pull/20780?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 [#20780](https://codecov.io/gh/apache/superset/pull/20780?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (f18f6bc) into [master](https://codecov.io/gh/apache/superset/commit/a64cdec8c299cd572c12a271b695b1a83c521cee?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a64cdec) will **decrease** coverage by `11.50%`.
   > The diff coverage is `60.00%`.
   
   > :exclamation: Current head f18f6bc differs from pull request most recent head f69a959. Consider uploading reports for the commit f69a959 to get more accurate results
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #20780       +/-   ##
   ===========================================
   - Coverage   66.30%   54.79%   -11.51%     
   ===========================================
     Files        1756     1756               
     Lines       66737    66740        +3     
     Branches     7049     7049               
   ===========================================
   - Hits        44251    36572     -7679     
   - Misses      20689    28371     +7682     
     Partials     1797     1797               
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | hive | `53.27% <60.00%> (-0.01%)` | :arrow_down: |
   | mysql | `?` | |
   | postgres | `?` | |
   | presto | `53.13% <60.00%> (-0.01%)` | :arrow_down: |
   | python | `57.83% <60.00%> (-23.73%)` | :arrow_down: |
   | sqlite | `?` | |
   | unit | `50.27% <20.00%> (-0.01%)` | :arrow_down: |
   
   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/20780?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/connectors/sqla/models.py](https://codecov.io/gh/apache/superset/pull/20780/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvY29ubmVjdG9ycy9zcWxhL21vZGVscy5weQ==) | `77.71% <33.33%> (-12.62%)` | :arrow_down: |
   | [superset/utils/database.py](https://codecov.io/gh/apache/superset/pull/20780/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-c3VwZXJzZXQvdXRpbHMvZGF0YWJhc2UucHk=) | `85.29% <100.00%> (+0.44%)` | :arrow_up: |
   | [superset/utils/dashboard\_import\_export.py](https://codecov.io/gh/apache/superset/pull/20780/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/update.py](https://codecov.io/gh/apache/superset/pull/20780/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%> (-88.89%)` | :arrow_down: |
   | [superset/key\_value/commands/delete.py](https://codecov.io/gh/apache/superset/pull/20780/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/key\_value/commands/delete\_expired.py](https://codecov.io/gh/apache/superset/pull/20780/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/20780/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=) | `15.62% <0.00%> (-76.25%)` | :arrow_down: |
   | [superset/datasets/commands/update.py](https://codecov.io/gh/apache/superset/pull/20780/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.30% <0.00%> (-68.68%)` | :arrow_down: |
   | [superset/datasets/commands/create.py](https://codecov.io/gh/apache/superset/pull/20780/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-c3VwZXJzZXQvZGF0YXNldHMvY29tbWFuZHMvY3JlYXRlLnB5) | `29.41% <0.00%> (-68.63%)` | :arrow_down: |
   | [superset/datasets/commands/importers/v0.py](https://codecov.io/gh/apache/superset/pull/20780/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.03% <0.00%> (-67.45%)` | :arrow_down: |
   | ... and [279 more](https://codecov.io/gh/apache/superset/pull/20780/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) | |
   
   


-- 
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] zhaoyongjie commented on a diff in pull request #20780: fix: unexpected commit causes pytest failure

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


##########
tests/integration_tests/sqla_models_tests.py:
##########
@@ -472,8 +472,6 @@ def test_fetch_metadata_for_updated_virtual_table(self):
         assert VIRTUAL_TABLE_STRING_TYPES[backend].match(cols["mycase"].type)
         assert cols["expr"].expression == "case when 1 then 1 else 0 end"
 
-        db.session.delete(table)

Review Comment:
   The table is not persistent. (456L)



-- 
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] zhaoyongjie commented on a diff in pull request #20780: fix: unexpected commit causes pytest failure

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


##########
superset/utils/database.py:
##########
@@ -39,10 +39,7 @@ def get_or_create_db(
     from superset.models import core as models
 
     database = (
-        db.session.query(models.Database)
-        .filter_by(database_name=database_name)
-        .autoflush(False)
-        .first()
+        db.session.query(models.Database).filter_by(database_name=database_name).first()

Review Comment:
   Although the Select can also be placed in a transaction, it relies on the subsequent commit(), which is not useful.



-- 
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] zhaoyongjie commented on pull request #20780: fix: unexpected commit causes pytest failure

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

   > Can you provide more context about this? How is the `autoflush` rule changed?
   
   The test case `tests/integration_tests/sqla_models_tests.py::TestDatabaseModel::test_fetch_metadata_for_updated_virtual_table` has a line as following, the `fetch_metadata(commit=False)` means that don't perform `commit` immediately in the function call. 
   
   https://github.com/apache/superset/blob/81bd4968d0a916cb2a20e47b20e31a1434be4f46/tests/integration_tests/sqla_models_tests.py#L454-L456
   
   but this transaction was interrupted by `get_or_create_db`, ---- the `commit()` would be executed whenever call the `get_or_create_db`.
   
   https://github.com/apache/superset/blob/81bd4968d0a916cb2a20e47b20e31a1434be4f46/superset/utils/database.py#L34-L64
   
   The strange thing is that this only happens under Postgres, and only after the [SQLAlchemy update](https://github.com/apache/superset/pull/19890). 
   
   You can observe that [L44](https://github.com/apache/superset/blob/81bd4968d0a916cb2a20e47b20e31a1434be4f46/superset/utils/database.py#L44) has a call `autoflash(False)`. This means that the **select statement** is also executed inside the transaction. 
   
   Sorry I didn't delve into SQLAlchmey and PG dialects to continue research, ----- just remove autoflash(False) and prevent execute commit() if no need.
   


-- 
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] michael-s-molina commented on pull request #20780: fix: unexpected commit causes pytest failure

Posted by GitBox <gi...@apache.org>.
michael-s-molina commented on PR #20780:
URL: https://github.com/apache/superset/pull/20780#issuecomment-1190102044

   Pinging @betodealmeida for awareness


-- 
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] zhaoyongjie commented on a diff in pull request #20780: fix: unexpected commit causes pytest failure

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


##########
superset/utils/database.py:
##########
@@ -56,8 +56,6 @@ def get_or_create_db(
             database_name=database_name, uuid=uuids.get(database_name)
         )
         db.session.add(database)
-
-    if database:

Review Comment:
   Execute commit only in the creation.



-- 
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] zhaoyongjie commented on a diff in pull request #20780: fix: unexpected commit causes pytest failure

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


##########
superset/utils/database.py:
##########
@@ -56,8 +56,6 @@ def get_or_create_db(
             database_name=database_name, uuid=uuids.get(database_name)
         )
         db.session.add(database)
-
-    if database:

Review Comment:
   Execute commit only in the creation.



-- 
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] zhaoyongjie merged pull request #20780: fix: unexpected commit causes pytest failure

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


-- 
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] geido commented on pull request #20780: fix: unexpected commit causes pytest failure

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

   Hello @zhaoyongjie thanks for the PR!
   
   > The latest SQLAlchemy https://github.com/apache/superset/pull/19890 seems to be changing the autoflush rule
   
   Can you provide more context about this? How is the `autoflush` rule changed?


-- 
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] zhaoyongjie commented on a diff in pull request #20780: fix: unexpected commit causes pytest failure

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


##########
tests/integration_tests/sqla_models_tests.py:
##########
@@ -472,8 +472,6 @@ def test_fetch_metadata_for_updated_virtual_table(self):
         assert VIRTUAL_TABLE_STRING_TYPES[backend].match(cols["mycase"].type)
         assert cols["expr"].expression == "case when 1 then 1 else 0 end"
 
-        db.session.delete(table)

Review Comment:
   The table is not persistent. (456L)



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