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/10/06 03:14:06 UTC
[GitHub] [superset] zhaoyongjie opened a new pull request, #21713: feat: support None operand with equal operator
zhaoyongjie opened a new pull request, #21713:
URL: https://github.com/apache/superset/pull/21713
### SUMMARY
This PR intends to support the `None` operand with `Equal` and `Not-Equal` operators in Filters in QueryObject. Currently, the `In` operator had supported `None` operand calculation, in order to align that the `Equal` and` Not-Equal` should support as well.
```Python
>>> result = mock_dataset.query({
"metrics": ["count"],
"filter": [{"col": "col", "val": None, "op": "=="}],
"is_timeseries": False,
})
>>> result.query
SELECT count(*) AS count
FROM mock_dataset
WHERE col IS NULL
```
### 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] codecov[bot] commented on pull request #21713: feat: support None operand with equal operator
Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #21713:
URL: https://github.com/apache/superset/pull/21713#issuecomment-1269255789
# [Codecov](https://codecov.io/gh/apache/superset/pull/21713?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 [#21713](https://codecov.io/gh/apache/superset/pull/21713?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2406683) into [master](https://codecov.io/gh/apache/superset/commit/51c54b3c9bc69273bb5da004b8f9a7ae202de8fd?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (51c54b3) will **decrease** coverage by `11.49%`.
> The diff coverage is `100.00%`.
```diff
@@ Coverage Diff @@
## master #21713 +/- ##
===========================================
- Coverage 66.78% 55.28% -11.50%
===========================================
Files 1799 1799
Lines 68881 68881
Branches 7319 7319
===========================================
- Hits 46002 38083 -7919
- Misses 20992 28911 +7919
Partials 1887 1887
```
| Flag | Coverage Δ | |
|---|---|---|
| hive | `?` | |
| mysql | `?` | |
| postgres | `?` | |
| presto | `52.81% <100.00%> (?)` | |
| python | `57.56% <100.00%> (-23.76%)` | :arrow_down: |
| sqlite | `?` | |
| unit | `50.95% <0.00%> (ø)` | |
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/21713?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/charts/schemas.py](https://codecov.io/gh/apache/superset/pull/21713/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-c3VwZXJzZXQvY2hhcnRzL3NjaGVtYXMucHk=) | `99.35% <ø> (ø)` | |
| [superset/connectors/sqla/models.py](https://codecov.io/gh/apache/superset/pull/21713/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.37% <100.00%> (-12.71%)` | :arrow_down: |
| [superset/utils/dashboard\_import\_export.py](https://codecov.io/gh/apache/superset/pull/21713/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/tags/core.py](https://codecov.io/gh/apache/superset/pull/21713/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-c3VwZXJzZXQvdGFncy9jb3JlLnB5) | `4.54% <0.00%> (-95.46%)` | :arrow_down: |
| [superset/key\_value/commands/update.py](https://codecov.io/gh/apache/superset/pull/21713/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%> (-90.91%)` | :arrow_down: |
| [superset/key\_value/commands/delete.py](https://codecov.io/gh/apache/superset/pull/21713/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%> (-87.88%)` | :arrow_down: |
| [superset/db\_engines/hive.py](https://codecov.io/gh/apache/superset/pull/21713/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/21713/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%> (-84.00%)` | :arrow_down: |
| [superset/dashboards/commands/importers/v0.py](https://codecov.io/gh/apache/superset/pull/21713/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/21713/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.00% <0.00%> (-69.05%)` | :arrow_down: |
| ... and [286 more](https://codecov.io/gh/apache/superset/pull/21713/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) | |
: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] zhaoyongjie commented on a diff in pull request #21713: feat: support None operand with equal operator
Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on code in PR #21713:
URL: https://github.com/apache/superset/pull/21713#discussion_r988529397
##########
tests/integration_tests/sqla_models_tests.py:
##########
@@ -659,51 +660,90 @@ def test_filter_on_text_column(text_column_table):
assert result_object.df["count"][0] == 1
-def test_should_generate_closed_and_open_time_filter_range():
- with app.app_context():
- if backend() != "postgresql":
- pytest.skip(f"{backend()} has different dialect for datetime column")
-
- table = SqlaTable(
- table_name="temporal_column_table",
- sql=(
- "SELECT '2021-12-31'::timestamp as datetime_col "
- "UNION SELECT '2022-01-01'::timestamp "
- "UNION SELECT '2022-03-10'::timestamp "
- "UNION SELECT '2023-01-01'::timestamp "
- "UNION SELECT '2023-03-10'::timestamp "
- ),
- database=get_example_database(),
- )
- TableColumn(
- column_name="datetime_col",
- type="TIMESTAMP",
- table=table,
- is_dttm=True,
- )
- SqlMetric(metric_name="count", expression="count(*)", table=table)
- result_object = table.query(
+@only_postgresql
+def test_should_generate_closed_and_open_time_filter_range(login_as_admin):
+ table = SqlaTable(
+ table_name="temporal_column_table",
+ sql=(
+ "SELECT '2021-12-31'::timestamp as datetime_col "
+ "UNION SELECT '2022-01-01'::timestamp "
+ "UNION SELECT '2022-03-10'::timestamp "
+ "UNION SELECT '2023-01-01'::timestamp "
+ "UNION SELECT '2023-03-10'::timestamp "
+ ),
+ database=get_example_database(),
+ )
+ TableColumn(
+ column_name="datetime_col",
+ type="TIMESTAMP",
+ table=table,
+ is_dttm=True,
+ )
+ SqlMetric(metric_name="count", expression="count(*)", table=table)
+ result_object = table.query(
+ {
+ "metrics": ["count"],
+ "is_timeseries": False,
+ "filter": [],
+ "from_dttm": datetime(2022, 1, 1),
+ "to_dttm": datetime(2023, 1, 1),
+ "granularity": "datetime_col",
+ }
+ )
+ """ >>> result_object.query
+ SELECT count(*) AS count
+ FROM
+ (SELECT '2021-12-31'::timestamp as datetime_col
+ UNION SELECT '2022-01-01'::timestamp
+ UNION SELECT '2022-03-10'::timestamp
+ UNION SELECT '2023-01-01'::timestamp
+ UNION SELECT '2023-03-10'::timestamp) AS virtual_table
+ WHERE datetime_col >= TO_TIMESTAMP('2022-01-01 00:00:00.000000', 'YYYY-MM-DD HH24:MI:SS.US')
+ AND datetime_col < TO_TIMESTAMP('2023-01-01 00:00:00.000000', 'YYYY-MM-DD HH24:MI:SS.US')
+ """
+ assert result_object.df.iloc[0]["count"] == 2
+
+
+def test_none_operand_in_filter(login_as_admin, physical_dataset):
+ expected_results = [
Review Comment:
This test case is the new one.
--
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 #21713: feat: support None operand with equal operator
Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on code in PR #21713:
URL: https://github.com/apache/superset/pull/21713#discussion_r988528676
##########
tests/integration_tests/sqla_models_tests.py:
##########
@@ -659,51 +660,90 @@ def test_filter_on_text_column(text_column_table):
assert result_object.df["count"][0] == 1
-def test_should_generate_closed_and_open_time_filter_range():
- with app.app_context():
- if backend() != "postgresql":
- pytest.skip(f"{backend()} has different dialect for datetime column")
-
- table = SqlaTable(
- table_name="temporal_column_table",
- sql=(
- "SELECT '2021-12-31'::timestamp as datetime_col "
- "UNION SELECT '2022-01-01'::timestamp "
- "UNION SELECT '2022-03-10'::timestamp "
- "UNION SELECT '2023-01-01'::timestamp "
- "UNION SELECT '2023-03-10'::timestamp "
- ),
- database=get_example_database(),
- )
- TableColumn(
- column_name="datetime_col",
- type="TIMESTAMP",
- table=table,
- is_dttm=True,
- )
- SqlMetric(metric_name="count", expression="count(*)", table=table)
- result_object = table.query(
+@only_postgresql
+def test_should_generate_closed_and_open_time_filter_range(login_as_admin):
Review Comment:
bycatch: use `only_postgresql` decorator narrowing test case, and use `login_as_admin` to define the Flask app context, there's no logical change.
--
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 #21713: feat: support None operand in EQUAL operator
Posted by GitBox <gi...@apache.org>.
zhaoyongjie merged PR #21713:
URL: https://github.com/apache/superset/pull/21713
--
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 #21713: feat: support None operand with equal operator
Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on code in PR #21713:
URL: https://github.com/apache/superset/pull/21713#discussion_r988528676
##########
tests/integration_tests/sqla_models_tests.py:
##########
@@ -659,51 +660,90 @@ def test_filter_on_text_column(text_column_table):
assert result_object.df["count"][0] == 1
-def test_should_generate_closed_and_open_time_filter_range():
- with app.app_context():
- if backend() != "postgresql":
- pytest.skip(f"{backend()} has different dialect for datetime column")
-
- table = SqlaTable(
- table_name="temporal_column_table",
- sql=(
- "SELECT '2021-12-31'::timestamp as datetime_col "
- "UNION SELECT '2022-01-01'::timestamp "
- "UNION SELECT '2022-03-10'::timestamp "
- "UNION SELECT '2023-01-01'::timestamp "
- "UNION SELECT '2023-03-10'::timestamp "
- ),
- database=get_example_database(),
- )
- TableColumn(
- column_name="datetime_col",
- type="TIMESTAMP",
- table=table,
- is_dttm=True,
- )
- SqlMetric(metric_name="count", expression="count(*)", table=table)
- result_object = table.query(
+@only_postgresql
+def test_should_generate_closed_and_open_time_filter_range(login_as_admin):
Review Comment:
bycatch: use `only_postgresql` decorator narrowing test case, and use `login_as_admin` to define the Flask app context.
--
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] john-bodley commented on pull request #21713: feat: support None operand in EQUAL operator
Posted by GitBox <gi...@apache.org>.
john-bodley commented on PR #21713:
URL: https://github.com/apache/superset/pull/21713#issuecomment-1306338296
@zhaoyongjie did you address the frontend issues that @villebro mentioned in a separate PR? If so could you reference this PR in said PR so there's a edge connecting the two PRs?
--
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 #21713: feat: support None operand in EQUAL operator
Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on PR #21713:
URL: https://github.com/apache/superset/pull/21713#issuecomment-1306495974
@john-bodley I will do these cases. thanks for the mention.
--
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 #21713: feat: support None operand in EQUAL operator
Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on PR #21713:
URL: https://github.com/apache/superset/pull/21713#issuecomment-1269604424
@villebro Thanks a lot, I will fix the frontend problem in the separated PR.
--
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 #21713: feat: support None operand with equal operator
Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on code in PR #21713:
URL: https://github.com/apache/superset/pull/21713#discussion_r988528676
##########
tests/integration_tests/sqla_models_tests.py:
##########
@@ -659,51 +660,90 @@ def test_filter_on_text_column(text_column_table):
assert result_object.df["count"][0] == 1
-def test_should_generate_closed_and_open_time_filter_range():
- with app.app_context():
- if backend() != "postgresql":
- pytest.skip(f"{backend()} has different dialect for datetime column")
-
- table = SqlaTable(
- table_name="temporal_column_table",
- sql=(
- "SELECT '2021-12-31'::timestamp as datetime_col "
- "UNION SELECT '2022-01-01'::timestamp "
- "UNION SELECT '2022-03-10'::timestamp "
- "UNION SELECT '2023-01-01'::timestamp "
- "UNION SELECT '2023-03-10'::timestamp "
- ),
- database=get_example_database(),
- )
- TableColumn(
- column_name="datetime_col",
- type="TIMESTAMP",
- table=table,
- is_dttm=True,
- )
- SqlMetric(metric_name="count", expression="count(*)", table=table)
- result_object = table.query(
+@only_postgresql
+def test_should_generate_closed_and_open_time_filter_range(login_as_admin):
Review Comment:
bycatch: use `only_postgresql` decorator to narrow the test case, and use `login_as_admin` to define the Flask app context, there's no logical change.
--
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