passren / PyDynamoDB

PyDynamoDB is a Python DB API 2.0 (PEP 249) client for Amazon DynamoDB. A SQLAlchemy dialect is offered as well. Superset official database driver.
Other
17 stars 3 forks source link

WHERE clauses are not pushed down to PartiQL? #33

Closed yang closed 1 year ago

yang commented 1 year ago

Thank you for making this library!

If I issue:

SELECT * FROM "cache" WHERE "my-value" != ''

to both boto3 directly (pure PartiQL) and to pydynamodb, pydynamodb never returns (the table is large).

I see that the statement it pushes down is SELECT * FROM "cache".

I am guessing it is eagerly pre-fetching data and locally evaluating the WHERE.

I would expect the entire SELECT statement to be pushed down as it is to PartiQL, which is able to handle this.

passren commented 1 year ago

@yang pydynamodb should push down the entire SQL to boto3 for execution. I will check if there is an issue with parsing the SQL while the clauses in "where" get cut. Thanks for your response.

passren commented 1 year ago

@yang Aha... I caught this little bug. I forgot to support "!=" operator in the SQL syntax parser here.

pydynamodb\sql\common.py

COMPARISON_OPERATORS = one_of("= <> < > >= <=")("comparison_operators").set_name(
    "comparison_operators"
)

It just needs simply adding it in:

COMPARISON_OPERATORS = one_of("= <> != < > >= <=")("comparison_operators").set_name(
    "comparison_operators"
)

It will be fixed in the next minor version.

yang commented 1 year ago

Wonderful, thank you!

yang commented 1 year ago

Would you mind also publishing the new version on pypi? Thanks!

passren commented 1 year ago

@yang It was there. You are able to upgrade to v0.5.1 using pip.