Search code examples
sqlsyntaxsnowflake-cloud-data-platform

Special characters used in Snowflake syntax: => and @


I am fairly experienced with SQL but I am new to Snowflake.

Learning about functions I came across with => like this, for example:

CREATE function  functions.public.area_of_circle (radius float)
Returns float as
$$
pi()*radius*radius
$$;

--call the function
select functions.public.area_of_circle(radius => 4);

Using COPY with data in stages I came across @ in front of the stage's name like this:

copy into intl_db.public.INT_STDS_ORG_3166
from @util_db.public.aws_s3_bucket
files = ( 'ISO_Countries_UTF8_pipe.csv')
file_format = ( format_name='util_db.public.PIPE_DBLQUOTE_HEADER_CR');

I couldn't find much relevant information about these in the SQL or Snowflake documentation.

For @ I saw a forum entry (not about Snowflake) suggesting it is for connecting to external DBs maybe? You don't need this though when you pull fields across different DBs, this appear to specifically apply to stages only for some reason.

I couldn't find anything specific on =>.

Are these just Snowflake specific syntaxes in some specific scenarios and there isn't more to these? I am just not sure why not use SQL syntax? Or do these actually mean anything across certain SQL languages?


Solution

  • => is the convention for passing named arguments to a Snowflake function or stored procedure. It is analogous to what you would find in comparable Python or other languages

    def some_function(name):
        # do something with name
        return something_else
    
    x = some_function(name="Dev")
    

    The @ is used when referring to Snowflake stages. I am not aware of any documentation that explains why Snowflake requires the @ symbol.