How to Add Filter in DynamoDB Query with Number Set using Java SDK/PartiQL?

0

Hi.

I have a table that has Number Set attribute, Field1.

Sample items

Field1 (Number Set)Field2Field3
[1,2,3]DataData
[2]DataData
[3]DataData
[2,4]DataData

How to Add Filter in DynamoDB Query with Number Set using Java SDK/PartiQL? The search sets only 1 param to get the items.

Sample scenario:

  • Include 2 as Field1 filter, the result should have rows #1, #2, #4.
  • Include 3 as Field1 filter. the result should have rows #1, #3.

Thank you!

asked 2 years ago819 views
1 Answer
1
Accepted Answer

In the PartiQL query editor the queries would look like:

SELECT * FROM "tablename" WHERE contains("field1", 2)

SELECT * FROM "tablename" WHERE contains("field1", 3)

I have never created any JAVA client but reading the docs it would be someting like

statement = new ParameterizedStatement()
     .withStatement("SELECT * FROM 'tablename' WHERE contains('field1', ?)")
     .withParameters(new AttributeValue(2))
profile picture
JaccoPK
answered 2 years ago
  • cool! tried the PartiQL in the console and worked! greatly appreciate the answer.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions