7

I have seen the dynamoDB doc for the PartiQL syntax:

SELECT expression  [, ...] 
FROM table[.index]
[ WHERE condition ] [ [ORDER BY key  [DESC|ASC] , ...]

but in practice:

select * from dev .pk-all-index
where "pk" = 'config' AND ("brand" = 'tesla' OR contains("aliases", 'tesla.com'))

gives me the error:

An error occurred during the execution of the command. ValidationException: Statement wasn't well formed, can't be processed: Unexpected keyword

fred_
  • 1,486
  • 1
  • 19
  • 31

2 Answers2

14
from "tablename"."indexname"
Dharman
  • 30,962
  • 25
  • 85
  • 135
tang chao
  • 172
  • 1
  • 2
  • 4
    Please add some explanation to your answer such that others can learn from it – Nico Haase Feb 10 '21 at 10:20
  • 2
    hmmm i feel like this is straightforward enough? – tang chao Feb 16 '21 at 04:49
  • 1
    Is it? What does your answer tell the OP? It does not contain a valid SQL statement, it does not contain the table names used in his own query, it does not tell him what he did wrong – Nico Haase Feb 16 '21 at 07:03
  • This syntax is documented here https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SQLtoNoSQL.Indexes.QueryAndScan.html – Luke Jan 29 '23 at 10:05
6

You might want to put the table name and index under quotes, individually.

SELECT * FROM "dev"."pk-all-index" WHERE "pk" = 'config' AND ("brand" = 'tesla' OR contains("aliases", 'tesla.com'))
Piyush Vishwakarma
  • 1,816
  • 3
  • 16
  • 24