postgres-aws-s3 icon indicating copy to clipboard operation
postgres-aws-s3 copied to clipboard

Error while export using aws_s3.query_export_to_s3 function.

Open Magvegva opened this issue 2 years ago • 1 comments

Hello! I'm just trying to use your aws_s3 extention.

When runing this query

SELECT * FROM aws_s3.query_export_to_s3( query => ' select
json_agg(post_main_approved) from asmo.post_main_approved limit 10 ; ', bucket => 'arn:aws:s3:::asmo-ij-json', file_path => 'test.json', region => 'eu-central-1a', access_key => '<access_key>', secret_key => '<secret_key>' );

then get this error:

error fetching next item from iterator. spiexceptions.SyntaxError: syntax error at or near ";"

Can you help to deal with this issue? Thanks!

Magvegva avatar Aug 09 '23 12:08 Magvegva

I believe this is caused by the semicolon used to terminate your query following the limit parameter, I.e. limit 10;. Try removing the semicolon.

I was having the same issue while trying to inline my uri creation like so;

const statement: string = `SELECT * FROM aws_s3.query_export_to_s3( \
  'SELECT * FROM ${tablename}', \
  aws_commons.create_s3_uri( \
    ${bucket_name}, \
    ${csv_out_path}, \
    ${region} \
  ); \  ${/* <= spiexceptions.SyntaxError: syntax error at or near ";" */}
);`

ford-jones avatar Nov 25 '25 02:11 ford-jones