根据 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 来完成任务。

Person(id,firstName,Lastname)
Selection(perId,check)

例子

    Id   |        Firstname           |   lastName   
    04   |           John             |           Luie
    09   |           Ben              |         Johnson

最初选择 Table 是空的。所以在检查了 person table 的条件后,即 if

因此在执行任务后,选择 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
)