It seems you cannot have a column containing a hyphen, foo-bar, while using it the KeyConditionExpression.
In your example, the .withKeyConditionExpression("#k = :v")
• is expended to .f("foo-bar = val"),
• which is similar to .f("foo - bar = val") (note the spaces around -).
The - is no longer interpreted as a character in a column name, but as an operand.
For obvious reasons, this will throw an error, because the - is not in an allowed position.