snowflake parquet load schema generation

Viewed 581

Working on loading parquet file to snowflake table from S3 location. This is what I am doing:

  1. created target table
CREATE TABLE myschema.target_table(
 col1 DATE,
 col2 VARCHAR);
  1. Created stage table using the following command
CREATE OR REPLACE TEMPORARY STAGE myschema.stage_table 
   url = 's3://mybucket/myfolder1/' 
 storage_integration = My_int 
 fileformat = (type = 'parquet')
  1. Load the target table from the stage table
COPY INTO myschema.target_table FROM(
  SELECT $1:col1::date,
         $1:col2:varchar
  FROM myschema.stage_table)

This works fine, my issue is, I have 10s of tables with 10s of columns. Is there any way to optimize the step 3, where I dont have to explicitly mention column names, so that code will become generic:

 COPY INTO myschema.target_table FROM(
  SELECT *
  FROM myschema.stage_table)
1 Answers
Related