title: dynamodb PartiQL SELECT query returns ValidationException: Unexpected from source
body: <p>I am using Amplify to setup a dynamodb with a corresponding lambda using the amplify blueprint for dynamodb.</p>
  <p>Accessing the dynamodb the &quot;classic&quot; way with KeyConditionExpression etc works just fine but today I wanted to try and use PartiQL instead with the executeStatement and I am just not able to get it to work.</p>
  <p>I have added the &quot;dynamodb:PartiQLSelect&quot; permission to the cloudfront template where all the other dynamodb permissions are so it looks like:</p>
  <pre><code> &quot;Action&quot;: [
                  &quot;dynamodb:DescribeTable&quot;,
                  &quot;dynamodb:GetItem&quot;,
                  &quot;dynamodb:Query&quot;,
                  &quot;dynamodb:Scan&quot;,
                  &quot;dynamodb:PutItem&quot;,
                  &quot;dynamodb:UpdateItem&quot;,
                  &quot;dynamodb:DeleteItem&quot;,
                  &quot;dynamodb:PartiQLSelect&quot;
                ],
  </code></pre>
  <p>and I do not get any permission error so I hope that part is ok, it does however return the same error even without that line added.</p>
  <p>The error that is always returned is:
  <strong>ValidationException: Unexpected from source&quot;</strong></p>
  <p>and no matter what I have tried, it does not help.
  My code is quite basic so far:</p>
  <pre><code>const dynamodb2 = new AWS.DynamoDB();
  
  let tableName = &quot;habits_sensors&quot;;
  if(process.env.ENV &amp;&amp; process.env.ENV !== &quot;NONE&quot;) {
    tableName = tableName + '-' + process.env.ENV;
  }
  
  app.get(path, function(req, res) {
    let params = {
      Statement: `select * from ${tableName}`
    };
  
    dynamodb2.executeStatement(params, (err, data) =&gt; {
      if (err) {
        res.statusCode = 500;
        res.json({error: `Could not get users from : ${tableName} =&gt;` + err});
      } else {
        res.json(data.Items);
      }
    });
  });
  
  </code></pre>
  <p>The complete error string returned from the lambda is:</p>
  <pre><code>{
      &quot;error&quot;: &quot;Could not get users from : habits_sensors-playground =&gt;ValidationException: Unexpected from source&quot;
  }
  </code></pre>
  <p>and I have the table habits_sensors-playground in my AWS account and I can access it the classic way without problems. That is why the &quot;Unexpected from source&quot; is confusing. I interpret it as referring to that the tableName (in from) in the select query is not correct but the name is matching what I have in AWS and it works using the documentclient.</p>
  <p>Any suggestion on what might be wrong is very appreciated.</p>