Extract part of string from row - azure-data-explorer

I am trying to run a kusto query and I need to extract offerThroughput from the row, please if you can advice. Thanks.
Sample data
"activityId_g","resourceDetails_s"
"dfcab056-2561-448a-9585-9bea6888e5ae","{id:H5Nd,_rid:H5Nd,_self:offers/H5Nd/,_ts:1657306008,_etag:0000ab18-0000-0300-0000-62c87b980000,offerVersion:V2,resource:dbs/sDVGAA==/colls/sDVGAKOxPdU=/,offerType:,offerResourceId:sDVGAKOxPdU=,content:{offerThroughput:1000,offerIsRUPerMinuteThroughputEnabled:false,offerIsAutoScaleEnabled:false}}"
"45c05db0-d503-42c3-be77-6a10c8fe7a68","{id:lEVo,_rid:lEVo,_self:offers/lEVo/,_ts:1659477250,_etag:00007500-0000-0300-0000-62e99d020000,offerVersion:V2,resource:dbs/sDVGAA==/colls/sDVGAK1hgXE=/,offerType:,offerResourceId:sDVGAK1hgXE=,content:{offerThroughput:8000,offerIsRUPerMinuteThroughputEnabled:false,offerIsAutoScaleEnabled:false}}"

datatable(activityId_g:guid, resourceDetails_s:string)
[
"dfcab056-2561-448a-9585-9bea6888e5ae","{id:H5Nd,_rid:H5Nd,_self:offers/H5Nd/,_ts:1657306008,_etag:0000ab18-0000-0300-0000-62c87b980000,offerVersion:V2,resource:dbs/sDVGAA==/colls/sDVGAKOxPdU=/,offerType:,offerResourceId:sDVGAKOxPdU=,content:{offerThroughput:1000,offerIsRUPerMinuteThroughputEnabled:false,offerIsAutoScaleEnabled:false}}"
,"45c05db0-d503-42c3-be77-6a10c8fe7a68","{id:lEVo,_rid:lEVo,_self:offers/lEVo/,_ts:1659477250,_etag:00007500-0000-0300-0000-62e99d020000,offerVersion:V2,resource:dbs/sDVGAA==/colls/sDVGAK1hgXE=/,offerType:,offerResourceId:sDVGAK1hgXE=,content:{offerThroughput:8000,offerIsRUPerMinuteThroughputEnabled:false,offerIsAutoScaleEnabled:false}}"
]
| parse resourceDetails_s with * "offerThroughput:" offerThroughput:int *
activityId_g
resourceDetails_s
offerThroughput
dfcab056-2561-448a-9585-9bea6888e5ae
{id:H5Nd,_rid:H5Nd,_self:offers/H5Nd/,_ts:1657306008,_etag:0000ab18-0000-0300-0000-62c87b980000,offerVersion:V2,resource:dbs/sDVGAA==/colls/sDVGAKOxPdU=/,offerType:,offerResourceId:sDVGAKOxPdU=,content:{offerThroughput:1000,offerIsRUPerMinuteThroughputEnabled:false,offerIsAutoScaleEnabled:false}}
1000
45c05db0-d503-42c3-be77-6a10c8fe7a68
{id:lEVo,_rid:lEVo,_self:offers/lEVo/,_ts:1659477250,_etag:00007500-0000-0300-0000-62e99d020000,offerVersion:V2,resource:dbs/sDVGAA==/colls/sDVGAK1hgXE=/,offerType:,offerResourceId:sDVGAK1hgXE=,content:{offerThroughput:8000,offerIsRUPerMinuteThroughputEnabled:false,offerIsAutoScaleEnabled:false}}
8000
Fiddle

Related

How do I retrieve data for a specific date in r?

Let's say if I want to retrieve the closing price for a cryptocurrency on 2022-09-01. I am sure my code is not correct.
BTC.todays_price <- BTC.charts$close %>% filter(BTC.charts$date = '2022-09-01')
Thanks in advance!
Try the following to conditionally select:
BTC.charts[BTC.charts$date == '2022-09-01', ]$close

Is there a way to fetch data from sqlite3 database into list using python more efficiently?

I have a list of words (100k+ elements). In database each word has corresponding id. I want to get these id-s into list as well.
I'm using following function, but it is very slow:
def fetch_id(word_list, cursor):
for word in word_list:
cursor.execute('SELECT id FROM entries_table WHERE word = ?',(word,))
data = cursor.fetchone()
if data is not None:
return data[0]
else: return None
Is there a way to make function faster?
cursor.execute("SELECT id FROM entries_table WHERE word in {}".format(str(tuple(word_list))))

mongolite filtering with dynamic array in r shiny

I have a select input with multiple options and my Mongo query
Here is the array if elements:
c<- c("elen","shallen")
query1 <- paste0('{"client": {"$in"["',c,'"]}')
#sales info is the data base
salesinfo$find(fields = '{"store":true,"_id":false}',query = query1)
Error: Invalid JSON object: {"client": [ elen ]}{"client": [ shallen ]}
this isn't working please help me please remember that it is a dynamic array and the values will change
After extensive research i found a way to solve the issue and i hope my solution will help out guys like me.
q1=paste(shQuote(c, type="cmd"), collapse=", ")
this step is to ensure you print out the array as a string and then use the query
query =paste0('{"store":{"$in":[',q1,']}}')
and the next step would be incorporating it to the query
salesinfo$find(fields = '{"store":true,"_id":false}',query = query)

add keys together in a dictionary

Hei guys! I need help in a python program. I wanna make a method which returns the sum of the keys as a dictionary. But I get a error "object is not iterable".
def totaltAntallSalg (dic) :
s = sum (dic.keys)
return s
call_function = totaltAntallSalg({"Ahmed":2,"Nada":1, "hala":3 })
How can I solve this problem?
thanks in advance
How can you add strings ? It might be values that you want to add.
To add values you may use following code:-
def totaltAntallSalg(dic):
D={}
D['sum']=sum(dic.values())
return D

Cognos Two Datetime Prompts Seconds Difference

I would like to calculate seconds difference between two datetime prompt values. I would like to do it by using query calculation. I'm using DB2 and i have to use DB2 functions. I have somthing like this but it didn't work for datetime prompts, it works only like this:
(DAYS(localtimestamp) - DAYS([FIRSTOCCURRENCE])) * 86400 +
(MIDNIGHT_SECONDS(localtimestamp) - MIDNIGHT_SECONDS([FIRSTOCCURRENCE]))
I want to use it like this :
(DAYS(?endDate?) - DAYS(?beginDate?)) * 86400 +
(MIDNIGHT_SECONDS(?endDate?) - MIDNIGHT_SECONDS(?beginDate?))
How can i do that ? Is there anyway to do this ?
PS: localtimestamp gives Aug 20, 2014 5:26:51 PM kind of result. But prompt gives 2014-08-21T10:53:09.166. Thats the main problem i couldn't convert it.
Try
_days_between(?endDate?;?beginDate?) * 86400 +
(extract(hour; #prompt('endDate', 'timestamp')#) - extract (hour; #prompt('beginDate', 'timestamp')#)) * 3600 +
(extract(minute; #prompt('endDate', 'timestamp')#) - extract (minute; #prompt('beginDate', 'timestamp')#)) * 60 +
extract(second; #prompt('endDate', 'timestamp')#) - extract (second; #prompt('beginDate', 'timestamp')#)
Query calculation should be like this, i finally figured it out:
(hour(substring (?endTime?,1,8))*3600+minute(substring (?endTime?,1,8))*60+second(substring (?endTime?,1,8)))-
(hour(substring (?beginTime?,1,8))*3600+minute(substring (?beginTime?,1,8))*60+second(substring (?beginTime?,1,8)))+_days_between (?endDate?,?beginDate?)*86400
There is Cogos Common Function CAST. It is processed by Cognos itself. You can convert days to seconds:
Cast (_days_between(?endDate?;?beginDate?), INTERVAL DAY TO SECOND)
It would be great if you can update your answer and mark where you need to use data items (in []), parameters (in ??), Cognos functions and separately DB2 functions.

Resources