โ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 a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโt want to miss the chance to attend and share knowledge.
If there isnโt a group near you, start one and help create a community that brings people together.
Request a New Group