0
votes

I have strings in the format "1234.567.111". I wish to break it into three int.

I do not see a split function in azure stream analytics. Is it possible to do this any other way.

Thanks

Update:

I have added a request for split function here.., would appreciate if you guys voted for the same..

2

2 Answers

1
votes

I wish Stream Analytics had a split function. You may have to use CHARINDEX and SUBSTRING for now: https://msdn.microsoft.com/en-us/library/azure/dn835064.aspx

It's a bit of a pain, but the following should work:

SELECT mystring
,SUBSTRING(
  mystring
  ,0
  ,CHARINDEX('.',mystring)
 ) as segment1
,SUBSTRING(
  mystring
  ,CHARINDEX('.',mystring)+1
  ,CHARINDEX('.',mystring,CHARINDEX('.',mystring)+1) - CHARINDEX('.',mystring) - 1
 ) as segment2
,SUBSTRING(
  mystring
  ,CHARINDEX('.',mystring,CHARINDEX('.',mystring)+1)+1
  ,999
 ) as segment3
from myinput

I would request a split function here (and post the link so we can vote): http://feedback.azure.com/forums/270577-azure-stream-analytics

0
votes

In case someone ends up here 7 years later like me 😅 Still no split function in 2022, but easy enough to create a simple JS UDF albeit probably with a small execution resource/time penalty

function main(splitstr, splitchar, index) {
    var res = null;

    try {
        res = splitstr.split(splitchar)[index];
    }catch(error){
        throw splitstr;
    }

    return res;
}