dynobase-icon
Dynobase

Error: dynamodb query key condition not supported

Rafal Wilinski

Answered by Rafal Wilinski

Last updated: October 23rd, 2026

Solution

Query key condition not supported means the expression does not match the target key schema or uses an unsupported key operator. For a table with a partition key and optional sort key, partition-key equality is required; a sort-key condition is optional.

Use = on the partition key. For the sort key, supported comparisons include =, <, <=, >, >= and BETWEEN. String and Binary sort keys also support begins_with. BETWEEN is not restricted to Number keys.

import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, QueryCommand } from "@aws-sdk/lib-dynamodb";

const db = DynamoDBDocumentClient.from(new DynamoDBClient({}));

const result = await db.send(new QueryCommand({
  TableName: "Orders",
  KeyConditionExpression: "pk = :pk AND begins_with(sk, :prefix)",
  ExpressionAttributeValues: { ":pk": "CUSTOMER#123", ":prefix": "ORDER#" },
}));

Do not use contains, OR, IN or non-key attributes in a conventional key condition. Move non-key criteria to FilterExpression, or choose a suitable index. When supplying IndexName, use that index's schema. Multi-attribute GSI keys have additional ordering rules; supply all partition-key attributes and follow the declared sort-key order.

See query guidance and AWS documentation.

Dynobase is a Professional GUI Client for DynamoDB

Start your 7-day free trial today

Product Features

Download
/
Changelog
/
Pricing
/
Member Portal
/
Privacy
/
EULA
/
Twitter
© 2026 Dynobase
+
Still using AWS DynamoDB Console?
Try Dynobase to accelerate your DynamoDB workflow. Start your 7-day free trial today.