'Snowflake external stage with multiple urls

I am creating an external stage, I want it to be based on 2 URLs.

PROBLEM 1

url1 = s3://bucket1/f1/2022/2/
url2 = s3://bucket1/f3/2022/2/

create or replace stage ext_stage url = ??????????
file_format=data_format
storage_integration=s3_integration;

How can I give 2 URLs in the external stage command? Is it possible?

PROBLEM 2

Also, I need to form the URLs.

I am thinking to use a procedure for it.

CREATE OR REPLACE PROCEDURE get_url()
  RETURNS STRING
  LANGUAGE SCALA
  RUNTIME_VERSION = '2.12'
  HANDLER = 'C.run'
  PACKAGES = ('com.snowflake:snowpark:latest')
  AS
  $$
    import java.util.Calendar
    object C{
      def run(session: com.snowflake.snowpark.Session): String = {
         try {
            val cal = Calendar.getInstance()
            val year =cal.get(Calendar.YEAR)
            var month =cal.get(Calendar.MONTH) + 1
            return "s3://bucket1/folder1/" + year + "/"+ month + "/"
           }
         catch {
              case e: Throwable => println("Not able to for url")
              return "Failed"
             }
      }
    }
  $$;

create or replace stage ext_stage url = call get_url()
file_format=data_format
storage_integration=s3_integration;


It is failing and I can not call the function. How can I call it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source