I am trying to create BQ routine which takes ARRAY as parameter and insert into table .
filename can be NULL too .
CREATE OR REPLACE PROCEDURE `##.history`( Job_ID STRING, filename ARRAY<STRING> , Status STRING )
BEGIN
EXECUTE IMMEDIATE format
("""
INSERT INTO
`##.tablename`
( JOB_ID,
FILENAME,
STATUS,
)
values
(GENERATE_UUID(),
'"""||Job_ID||"""',
'"""||filename|| """',
'"""||Status||"""'
)
""");
when I am invoking procedure it's giving error:
CALL ###.history('text1', ['f1.txt','f2.txt'], 'start');
No matching signature for operator || for argument types: STRING, ARRAY. Supported signatures: STRING || STRING; BYTES || BYTES; ARRAY || ARRAY
Your error is coming from the format statement and trying to concatenate the array, concatenation being a string function only. As Max Zolotenko pointed out, you probably don't need the
EXECUTE IMMEDIATEin the example you provided, you can proceed with something like:I do want to point out however in your example you have
GENERATE_UUID()that you are also trying to insert, however your values list only contains 3 columns. You'll need to adjust that as well.