I have two tables in AWS Redshift and need to insert some values into one table based on the entries of the other. I want to know if it is possible to accomplish the task using a AWS GLUE job, if so, will that be a good idea? Or should I use the query-editor/sqlworkbench in Redshift to accomplish the task.
Person(id,firstName,Lastname)
Selection(perId,check)
firstName
and lastName
of Person table lies in ['fullName1', 'fullName2',..]
then then insert 1 in the selection table otherwise 0 with the respective id of person. Example
the list values are: ['JohnLuie' , 'FranklinWatson']
person table
Id | Firstname | lastName
04 | John | Luie
09 | Ben | Johnson
Initially the Selection Table is empty. So after checking with the condition on person table That is if
(Person.firstName+ Person.lastName) in ['JohnLuie' , 'FranklinWatson]
then insert 1 or 0 in Selection.check with person.id in Selection.perIdSo after performing the task the Selection table will look like:
Selection
PerId | check
04 | 1
09 | 0
I want to know if I can perform the following task by running aws-glue job. Both the tables are in redshift.
You could just do it in an SQL query, something like:
INSERT INTO Selection
(
SELECT
Id,
CASE WHEN firstName || lastName IN ['JohnLuie' , 'FranklinWatson] THEN 1 ELSE 0 END
FROM person
)