Is CURRENT_TIMESTAMP a function in ANSI SQL?

869 Views Asked by At

I was using the bigquery function current_timestamp() when i discovered that you can use it without parenthesis if you want. Since it is a function, i would advocate for parenthesis, but what i find on the internet indicates that you can indeed use it without in different standards.

I found that in ANSI SQL 1992 it is indeed a function (based on this answer). Yet i did not find why it is allowed to call it without parenthesis and even if the standard advocates for parenthesis or not ? Snowflake is saying that it allows for a call without parenthesis to comply with ANSI SQL...

So does anyone knows what it is ?

Many thanks in advance !

1

There are 1 best solutions below

1
On BEST ANSWER

Based on 2.1.2.70 F411:

<current timestamp value function> ::=
 CURRENT_TIMESTAMP [ <left paren> <timestamp precision> <right paren> ]

It is a function and (<precision>) is optional so the following are correct:

SELECT CURRENT_TIMESTAMP;

SELECT CURRENT_TIMESTAMP(3);

Based on that definition SELECT CURRENT_TIMESTAMP() shouldn't work but often is implemented.

db<>fiddle demo - MySQL vs db<>fiddle demo - PostgreSQL