Can I use COUNT in a PartiQL query of a Dynamo table?

12.6k views Asked by At

Trying all of these in PartiQL Editor. DynamoDB > PartiQL editor on the AWS site.

Query: select count(divisionID) from "org-data-dev";

Result: ValidationException: Unexpected path component at 1:8:5

Query: select count("divisionID") from "org-data-dev";

Result: ValidationException: Unexpected path component at 1:8:5

Query: select count(*) from "org-data-dev";

Result: ValidationException: Unexpected path component at 1:8:5

Query: select divisionID from "org-data-dev";

Result: (query succeeds)

Is it just not possible to use COUNT in PartiQL for Dynamo? The error is misleading in that case.

Also what is the 5 in 1:8:5 -- first line, 8th character and 5th... what? It's a 2D space, 3 coordinates makes no sense.

3

There are 3 answers

1
hunterhacker On BEST ANSWER

You cannot do COUNT with DynamoDB PartiQL. You can project out just the keys and count the delivered results.

I don’t know what 1:8:5 indicates.

0
Alex Q On

The 5 in 1:8:5 is the length of the substring that is causing the error.

select count(divisionID) from "org-data-dev";
       ~~~~~
0
Yahya On

1:8:5 indicates 1 = line 8 = position of the character 5 = Number of character