Skip to content

BUG: GDAL does not raise error for invalid column in where expression for GPKG #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
brendan-ward opened this issue Mar 12, 2021 · 1 comment · Fixed by #150
Closed
Labels
bug Something isn't working

Comments

@brendan-ward
Copy link
Member

Observed in GDAL 3.2.1

Need to research if this is an upstream bug.

For geopackages, if we pass an invalid where expression that includes a column not present in the dataset, GDAL logs that to stderr but does not set an error or error message.

OGR_L_GetFeatureCount is returned as -1 in this case, which might be a clue that we need to look at output to stderr. Fix may be to add a custom error handler, at least around this function.

@brendan-ward brendan-ward added the bug Something isn't working label Mar 12, 2021
@theroggy
Copy link
Member

In pull request #74 a test is added to check the result of an invalid where on amongst others a GPKG, and this indeed confirms this issue.
If this issue gets fixed, the test will need to be corrected as well:

def test_read_where_invalid(naturalearth_lowres_all_ext):
    if naturalearth_lowres_all_ext.suffix in [".gpkg"]:
        # Geopackage doesn't raise, but returns empty df?
        gdf = read_dataframe(naturalearth_lowres_all_ext, where="invalid")
        assert len(gdf) == 0
    else:
        with pytest.raises(ValueError, match="Invalid SQL"):
            read_dataframe(naturalearth_lowres_all_ext, where="invalid")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants