EDIT: As @Prateek suggested, I changed my working flow - Now the first query is used as "Structure-Query" that I run every time that I want to clear and recreate my table with the desired variables structure. The second query became my "Population-Query", where I fill my empty structured table. The meaning is that now I have a bunch of sub-tables that my population-query joins and push at once.
Given this structured table with no rows:
CREATE OR REPLACE primary_table (
EVENT_ID int64,
TREATMENT_TIME timestamp,
AGE int64,
HEIGHT int64,
WEIGHT int64,
SEX string,
ICU_ADMIT timestamp,
ICU_DISCH timestamp,
ICUSTAYS_COUNT int64,
);
And after the initial population with the total wanted rows at the end of the day:
INSERT INTO primary_Table (
EVENT_ID,
TREATMENT_TIME
)
SELECT
event_id,
cast(treatment_time as timestamp)
FROM some_table_1
I have this half filled primary_table
:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…