Skip to main content

SPLIT_PART vs. SPLIT_PART2

  • May 30, 2018
  • 2 replies
  • 9 views

Forum|alt.badge.img+2

When I call the SPLIT_PART function, it looks like Vertica is running the SPLIT_PARTB function. This is confusing and not documented. If running SPLIT_PART means really running SPLIT_PARTB, we should at least mention that. It's preferable to fix the output;

=> SELECT SPLIT_PART('abc~@~def~@~ghi', '~@~', 2); 
 split_partb 
------------- 
 def 
(1 row) 

=> SELECT SPLIT_PART('123~|~456~|~789', '~|~', 3); 
 split_partb 
------------- 
 789 
(1 row) 

2 replies

Jim_Knicely
Forum|alt.badge.img+2
  • Participating Frequently
  • May 30, 2018

Hi,

I believe that SPLIT_PART switches to SPLIT_PARTB if using a binary locale.

Example:

Using a binary locale:

dbadmin=> show locale;
  name  |               setting
--------+--------------------------------------
 locale | en_US@collation=binary (LEN_KBINARY)
(1 row)

dbadmin=> SELECT SPLIT_PART('123|456|789', '|', 1);
 split_partb
-------------
 123
(1 row)

Change to a non-binary locale:

dbadmin=> SET LOCALE TO 'en_US@collation=standard';
INFO 2567:  Canonical locale: 'en_US@collation=standard'
Standard collation: 'LEN'
English (United States, collation=standard)
SET
dbadmin=> show locale;
  name  |            setting
--------+--------------------------------
 locale | en_US@collation=standard (LEN)
(1 row)

dbadmin=> SELECT SPLIT_PART('123|456|789', '|', 1);
 SPLIT_PART
------------
 123
(1 row)

Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • May 31, 2018

Thanks, Jim. I never would have figured that out. I'll add that info to the doc.