-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from jaceksan/working
NAS-2637: FDW - push down some filters Reviewed-by: https://github.com/pcerny
- Loading branch information
Showing
20 changed files
with
281 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# (C) 2021 GoodData Corporation | ||
|
||
import datetime | ||
|
||
import pytest | ||
|
||
from gooddata_fdw.environment import Qual | ||
from gooddata_fdw.fdw import MAX_DATE, MIN_DATE, GoodDataForeignDataWrapper | ||
from gooddata_sdk.compute_model import AbsoluteDateFilter, ObjId, PositiveAttributeFilter | ||
|
||
start_date = datetime.date(2021, 1, 1) | ||
end_date = datetime.date(2021, 2, 1) | ||
|
||
|
||
test_data = [ | ||
[ | ||
[Qual("datetime", ">=", start_date), Qual("car_model", ("=", True), ["Tesla", "Škoda"])], | ||
[ | ||
AbsoluteDateFilter(ObjId("datetime", "dataset"), "2021-01-01", MAX_DATE), | ||
PositiveAttributeFilter("car_model", ["Tesla", "Škoda"]), | ||
], | ||
], | ||
[ | ||
# This represents SQL BETWEEN operation | ||
[Qual("datetime", ">=", start_date), Qual("datetime", "<=", end_date)], | ||
[ | ||
AbsoluteDateFilter(ObjId("datetime", "dataset"), "2021-01-01", MAX_DATE), | ||
AbsoluteDateFilter(ObjId("datetime", "dataset"), MIN_DATE, "2021-02-02"), | ||
], | ||
], | ||
[ | ||
[Qual("datetime", "=", start_date)], | ||
[ | ||
AbsoluteDateFilter(ObjId("datetime", "dataset"), "2021-01-01", "2021-01-02"), | ||
], | ||
], | ||
[ | ||
[Qual("datetime", ">", start_date), Qual("datetime", "<", end_date)], | ||
[ | ||
AbsoluteDateFilter(ObjId("datetime", "dataset"), "2021-01-02", MAX_DATE), | ||
AbsoluteDateFilter(ObjId("datetime", "dataset"), MIN_DATE, "2021-02-01"), | ||
], | ||
], | ||
] | ||
|
||
|
||
@pytest.mark.parametrize("quals,expected", test_data) | ||
def test_quals(fdw_options_for_compute_table, test_compute_table_columns, quals, expected): | ||
fdw = GoodDataForeignDataWrapper(fdw_options_for_compute_table, test_compute_table_columns) | ||
filters = fdw.extract_filters_from_quals(quals) | ||
|
||
assert filters == expected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.