- Newest
- Most votes
- Most comments
The error you're encountering is likely due to how AWS Glue handles connection options when using a query instead of a table name. When using a query, Glue expects different parameters in the connection options.
To resolve this issue, try modifying your connection options as follows:
- Remove the "useConnectionProperties" parameter.
- Add a "dbtable" parameter with a placeholder value (e.g., "(SELECT 1) AS dummy").
- Keep your "query" parameter as is.
Here's how your connection options should look:
connection_psql_options_with_query = { "connectionName": "postgres13 jdbc connection", "dbtable": "(SELECT 1) AS dummy", "query": query }
This approach tells Glue to use the query you've provided while still satisfying the requirement for a "dbtable" parameter. The dummy table is not actually used, but its presence helps avoid the "key not found: location" error.
Also, ensure that your Glue job has the necessary permissions to access the PostgreSQL database, and that the network configuration (VPC, security groups, etc.) allows the connection from Glue to your database.
If you continue to experience issues, you may want to check the Glue job's CloudWatch logs for more detailed error messages, and verify that your connection details (host, port, database name, credentials) are correct in the Glue connection you're referencing.
Sources
DynamicFrameReader class - AWS Glue
AWS Glue and RDS Postgres Issue | AWS re:Post
Troublehsoot AWS Glue connection to a JDBC data source | AWS re:Post
answered 2 years ago
Relevant content
asked 4 years ago
- AWS OFFICIALUpdated 2 years ago

Tried your option but still didn't worked.
query = "select object_key from s3_event_logs limit 1" connection_psql_options_with_query = { "connectionName" : "postgres13 jdbc connection", "dbtable": "(SELECT 1) AS dummy", "query" : query }
Got the error as following: Error Category: RESOURCE_NOT_FOUND_ERROR; Failed Line Number: 52; An error occurred while calling o144.getSource. key not found: url