根据 Redshift 中其他 table 的条目在 table 中插入值
Insert values in a table based on entries of other table in Redshift
我在 AWS Redshift 中有两个 table,需要根据另一个的条目将一些值插入一个 table。我想知道是否可以使用 AWS GLUE 作业完成任务,如果可以,这是个好主意吗?或者我应该使用 Redshift 中的 query-editor/sqlworkbench 来完成任务。
- Table 1 具有以下架构:
Person(id,firstName,Lastname)
- Table 2 具有以下架构
Selection(perId,check)
- 如果 Person table 的
firstName
和 lastName
的串联位于 ['fullName1', 'fullName2',..]
中,则在选择 table 中插入 1,否则为 0人的各自ID。
例子
列表值为:['JohnLuie' , 'FranklinWatson']
人table
Id | Firstname | lastName
04 | John | Luie
09 | Ben | Johnson
最初选择 Table 是空的。所以在检查了 person table 的条件后,即 if
(Person.firstName+ Person.lastName) in ['JohnLuie' , 'FranklinWatson]
然后在 Selection.check 中插入 1 或 0,在 Selection.perId 中插入 person.id
因此在执行任务后,选择 table 将如下所示:
选择
PerId | check
04 | 1
09 | 0
我想知道我是否可以通过 运行 aws-glue 作业执行以下任务。 table 都处于红移状态。
您可以在 SQL 查询中执行此操作,例如:
INSERT INTO Selection
(
SELECT
Id,
CASE WHEN firstName || lastName IN ['JohnLuie' , 'FranklinWatson] THEN 1 ELSE 0 END
FROM person
)
我在 AWS Redshift 中有两个 table,需要根据另一个的条目将一些值插入一个 table。我想知道是否可以使用 AWS GLUE 作业完成任务,如果可以,这是个好主意吗?或者我应该使用 Redshift 中的 query-editor/sqlworkbench 来完成任务。
- Table 1 具有以下架构:
Person(id,firstName,Lastname)
- Table 2 具有以下架构
Selection(perId,check)
- 如果 Person table 的
firstName
和lastName
的串联位于['fullName1', 'fullName2',..]
中,则在选择 table 中插入 1,否则为 0人的各自ID。
例子
列表值为:
['JohnLuie' , 'FranklinWatson']
人table
Id | Firstname | lastName
04 | John | Luie
09 | Ben | Johnson
最初选择 Table 是空的。所以在检查了 person table 的条件后,即 if
(Person.firstName+ Person.lastName) in ['JohnLuie' , 'FranklinWatson]
然后在 Selection.check 中插入 1 或 0,在 Selection.perId 中插入 person.id
因此在执行任务后,选择 table 将如下所示:
选择
PerId | check
04 | 1
09 | 0
我想知道我是否可以通过 运行 aws-glue 作业执行以下任务。 table 都处于红移状态。
您可以在 SQL 查询中执行此操作,例如:
INSERT INTO Selection
(
SELECT
Id,
CASE WHEN firstName || lastName IN ['JohnLuie' , 'FranklinWatson] THEN 1 ELSE 0 END
FROM person
)