10-07-2019 09:05 AM
10-07-2019 09:28 AM
Hi @Barb Krienke, Please use %sql in Databricks notebook cell.
%sql
SELECT CHARINDEX('mer', 'Customer', 3) AS MatchPosition;
12-29-2019 09:04 PM
Hi @Shyamprasad Miryala
I added %sql to the notebook cell and it did not work.
Were you able to get it to work in Databricks?
10-14-2019 08:10 PM
%sql
--The closest thing I found was instr()
SELECT instr(Attribute, 'MatchString')
FROM TableA tba
12-29-2019 09:06 PM
Thanks for trying @jconno
Unfortunately I need to be able to specify the position where the search for the character needs to start. So just finding the first occurrence of the character is not going to help.
03-04-2020 07:48 PM
Hi @bkrienke,
It may usefull.
%sql
SELECT position('bar', 'foobarbar', 5);
-- 7
10-13-2020 10:14 PM
The best option I found to replace CHARINDEX was LOCATE, examples from the Spark documentation below
> SELECT locate('bar', 'foobarbar', 5);
7
> SELECT POSITION('bar' IN 'foobarbar');
4
Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections.
Click here to register and join today!
Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.