bug: filters not applied to joined tables
See original GitHub issueGiven, two tables, if they are joined, and then a filter is applied, the filter is actually being ignored:
import ibis
ibis.options.interactive = True
connection = ibis.sqlite.connect('data/geography.db')
countries = connection.table('countries')
gdp = connection.table('gdp')
expr = (countries.inner_join(gdp,
predicates=countries['iso_alpha3'] == gdp['country_code'])
.filter(gdp['year'] == 2017))
expr
Intuitively, the result should only contain the rows with year == 2017
, but the filter is not applied.
The database in this example can be found at: https://github.com/datapythonista/ibis/tree/tutorial/docs/source/tutorial/data
The SQL compiled from the expression, can be obtained with:
>>> str(expr.compile())
SELECT t0.iso_alpha2, t0.iso_alpha3, t0.iso_numeric, t0.fips, t0.name, t0.capital, t0.area_km2, t0.population, t0.continent, t0.country_code, t0.year, t0.value
FROM (SELECT t1.iso_alpha2 AS iso_alpha2, t1.iso_alpha3 AS iso_alpha3, t1.iso_numeric AS iso_numeric, t1.fips AS fips, t1.name AS name, t1.capital AS capital, t1.area_km2 AS area_km2, t1.population AS population, t1.continent AS continent, t2.country_code AS country_code, t2.year AS year, t2.value AS value
FROM base.countries AS t1 JOIN base.gdp AS t2 ON t1.iso_alpha3 = t2.country_code) AS t0, base.gdp
WHERE base.gdp.year = ?
Issue Analytics
- State:
- Created 3 years ago
- Comments:20 (20 by maintainers)
Top Results From Across the Web
Why a filter is not applying to another joined table?
Solved: I'm trying to filter all people who have had a meeting from the activity table and list the Skills attached from the...
Read more >"Filtering in related table could not be applied" error
This article describes a reason and possible resolution for the "Filtering in related table could not be applied" error.
Read more >Create and manage relationships in Power BI Desktop
If you query two or more tables at the same time, when the data is loaded, Power BI Desktop attempts to find and...
Read more >Templated Filters and Derived Tables - Variable not found ...
Derived tables are a common use case for applying templated filters. This is because templated filters allow us to restrict tables to ...
Read more >[Compiling error] Filtering On field from aggregate left join table
Add this filter in the join condition instead of the filter tab. It will probably fix your issue. Checking for nullidentifier on the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A third alternative is to call
materialize
in the filter:I would like to release after finishing the refactoring of the backends. Whenever that happens, but I think it’ll probably be in one week or two. If this is implemented by then it can surely be released, but I don’t see this as a blocker.