Blanks After Function Name - SQL Server to MariaDB Migration

In SQL Server you can have blank characters after the function name before parentheses. This is not allowed for some (not every) functions in MariaDB and blanks must be removed.

SQL Server:

  -- A blank after the function name
  SELECT SUBSTRING ('abc', 1, 2);
  # ab  
 
  -- A newline after the function name
  SELECT SUBSTRING
    ('abc', 1, 2);
  # ab
 

MariaDB:

  -- A blank after the function name
  SELECT SUBSTRING ('abc', 1, 2);
  # ERROR 1630 (42000): FUNCTION SUBSTRING does not exist. 
  # Check the 'Function Name Parsing and Resolution' section in the Reference Manual 
 
  -- A newline after the function name
  SELECT SUBSTRING
    ('abc', 1, 2);
  # ERROR 1630 (42000): FUNCTION SUBSTRING does not exist. 
 
  -- Without blanks after the function name
  SELECT SUBSTRING('abc', 1, 2);
  # ab

This also applies for some other functions:

MariaDB:

  SELECT COUNT (1) FROM t;
  # ERROR 1630 (42000): FUNCTION COUNT does not exist
 
  SELECT COUNT(1) FROM t;
  # 3
 
  SELECT NOW ();
  # ERROR 1630 (42000): FUNCTION now does not exist.
 
  SELECT NOW();
  # 2022-12-10 12:00:27

You can change this behavior and allow blanks after the function name by adding IGNORE_SPACE option to sql_mode:

MariaDB:

  -- Adding IGNORE_SPACE
  SET sql_mode=(SELECT CONCAT(@@sql_mode,',IGNORE_SPACE'));
 
  -- Now blanks are allowed
  SELECT NOW ();
  #  2022-12-10 12:31:58

Without IGNORE_SPACE option (i.e. by default), a blank is not allowed for the following functions in MariaDB:

1 ADDDATE
2 BIT_AND
3 BIT_OR
4 BIT_XOR
5 CAST
6 COUNT
7 CUME_DIST
8 CURDATE
9 CURTIME
10 DATE_ADD
11 DATE_SUB
12 DATE_FORMAT
13 DECODE
14 DENSE_RANK
15 EXTRACT
16 FIRST_VALUE
17 GROUP_CONCAT
18 LAG
19 LEAD
20 MAX
21 MEDIAN
22 MID
23 MIN
24 NOW
25 NTH_VALUE
26 NTILE
27 POSITION
28 PERCENT_RANK
29 PERCENTILE_CONT
30 PERCENTILE_DISC
31 RANK
32 ROW_NUMBER
33 SESSION_USER
34 STD
35 STDDEV
36 STDDEV_POP
37 STDDEV_SAMP
38 SUBDATE
39 SUBSTR
40 SUBSTRING
41 SUM
42 SYSDATE
43 SYSTEM_USER
44 TRIM
45 TRIM_ORACLE
46 VARIANCE
47 VAR_POP
48 VAR_SAMP

For more details, see SQL Server to MariaDB Migration.