- Newest
- Most votes
- Most comments
【以下的回答经过翻译处理】 我认为问题不在于作业标记,而是传递给PG实例的查询。在这里使用from_catalog方法查询数据库是行不通的。当我们使用from_catalog方法创建DynamicFrame时,Glue将首先查询列名,并检查PG实例。Glue会将列名折叠为小写,然后传递给PG实例。由于PG是大小写敏感的,它将尝试按名称ID搜索列,但找不到该列,因此会引发错误。
相反,我们需要直接从PG实例中读取,使用from_options方法。我请求您添加查询,但要将大小写敏感的列从查询中转义,以使用确切的列名以便Glue不将其折叠为小写,而PG引擎将能够在表中找到必需的列。以下是如何做到这一点的方法。
示例代码片段:
从 PG 读取
connection_pg_options = { "url": "jdbc:postgresql://<jdbc-host-name>:5432/db", "dbtable": "public.test", "user": "admin", "password": "pwd", "sampleQuery": "select "ID" from public.test", }
PGNode = glueContext.create_dynamic_frame.from_options(connection_type="postgresql", connection_options=connection_pg_options)
PGNode.show()
我在我的端上测试了这个PG模式。
create table with_case ("ID" int PRIMARY KEY, "firstName" varchar(10), "lastName" varchar(10));
Glue读取代码片段:
connection_pg_options = { "url": "jdbc:postgresql://.mydatabase.us-west-2.rds.amazonaws.com:5432/pilot", "dbtable": "public.with_case", "user": "postgres", "password": "mypassword", "sampleQuery": "select "ID" from public.with_case" }
PGNode = glueContext.create_dynamic_frame.from_options(connection_type="postgresql", connection_options=
Relevant content
- Accepted Answerasked a year ago
- asked 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 months ago