I have a file with data :
bq --schema
corp:STRING,
region:STRING,
load_date_time:TIMESTAMP)
bq --schema
corp:STRING,
load_date_time:TIMESTAMP)
and a String variable as :
table1
table2
What i want to do is to replace ')' to an array element and the final output should look like :
bq --schema
corp:STRING,
region:STRING,
load_date_time:TIMESTAMP table1
bq --schema
corp:STRING,
load_date_time:TIMESTAMP table2
The string variable is generated from below file :
CREATE TABLE UK_CHAIN_PARM_ADDL_FUNDING(
corp:STRING,
region:STRING,
prin:STRING,
assc:STRING,
chain:STRING,
acct_ind:STRING,
transit_nbr:INTEGER,
dda_nbr:STRING,
currency:STRING,
mask:STRING,
value_dt:INTEGER
)
CREATE TABLE UK_SUPPLEMENTAL_FUNDING(
merchant:STRING,
acct_ind:STRING,
transit_nbr:INTEGER,
dda_nbr:STRING,
currency:INTEGER,
mask:STRING,
value_dt:INTEGER,
beneficiary:STRING,
vbc_line_1:STRING
)
CREATE TABLE UK_REGION_PARM(
corp:STRING,
region:STRING,
end_point:STRING,
currency_code:STRING,
tax_id1:STRING,
tax_id2:STRING,
load_date_time:TIMESTAMP)
for extracting just table names i have used below command
Tablenames=$(grep -i 'create table' $myfilename | awk -F ' ' 'BEGIN{ORS="\n";}{print $3}' | tr "(" "\n")
So ultimately i want output in format
bq --schema "schema of the table" -t tablename