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

contains() or begins_with() don't work. #24

Closed ohjisu closed 1 year ago

ohjisu commented 1 year ago
  1. contains() and begins_with() are not available in PartiQL [SELECT statements].

The syntax below is executable. SELECT * FROM UserTB WHERE user_name = 'tes0125' Limit 2

contains() or begins_with() don't work. [SELECT statements] SELECT * FROM UserTB WHERE user_name = 'tes0125' AND begins_with(range_key, 'FRIEND#') Limit 2

  1. Is there any way to handle paging?
passren commented 1 year ago

@ohjisu Thanks for your feedback. For issue 1, the PartiQL functions were indeed ignored in previous releases. I will add them in. For paging, that is definitely a good idea. I will consider it as a new feature in the next release.

passren commented 1 year ago

@ohjisu 0.4.6 released to add PartiQL functions support.

Support following PartiQL functions: _begins_with, missing, attributetype, contains, size in SELECT. EXISTS function is not supported due to illegal SQL grammar.

For paging, you are able to use result_set.fetchmany(size) to get data with your page size.

ohjisu commented 1 year ago

Hi! Thanks for the quick update. I will use it after updating to the latest version(0.4.6).

ohjisu commented 1 year ago

I updated it to version 0.4.6 and tested it. _beginswith(), contains() Neither seems to work. If the limit is used together, the limit does not work either.

passren commented 1 year ago

@ohjisu I guess this problem is caused by wrong quotes in the functions. You have to use double-quote to embrace column name and single-quote to embrace value.

F.e. begins_with("col_str", 'Online')

Please refer to the examples here: Using the BEGINS_WITH function with PartiQL for DynamoDB

passren commented 1 year ago

@ohjisu Did this enhancement work for you? Can I close the issue? Looking forward to your feedback.

ohjisu commented 1 year ago

@passren Yes, I think it would be good to close the issue. Thank you.