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!

preguntada hace 2 años827 visualizaciones
1 Respuesta
1
Respuesta aceptada

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
respondido hace 2 años
  • cool! tried the PartiQL in the console and worked! greatly appreciate the answer.

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas