Skip to content
Advertisement

How to write FILE_FORMAT in Snowflake to Java code?

I am trying to execute COPY INTO statement in Java code like this:

And it works fine.

Is there any way to add this file_format in Java code, so there is no need to set it up in Snowflake?

For example, SQL code of file_format that I have set in Snowflake is

Is there any way to write this as Java code?

UPDATE

Here is the code where I am using copy into statement:

So how can I apply like file_format created on execution of query?

Advertisement

Answer

This is the solution that I found for my question.

To be able to write file_format from code and not create one in Snowflake I did like this:

I also added OVERWRITE = TRUE which means that if my file exists alredy in S3, overwrite it with new one.

single = true and max_file_size = 4900000000 means that I am allowing to export files big to 5 GB. If I haven’t added these two, my one big file would be separated in few smaller .csv files, which I did not want.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement