How to skip rows that have no data in specific column - jmeter

Ex:
"ActivityId":7177,"ReferenceId":0,"Key":0,"FirstName":"Kerthana","LastName":"thanneru","CId":"00050068953"
"ActivityId":6216,"ReferenceId":42234,"Key":0,"FirstName":"Krishna","LastName":"thanneru","CId":null,"Specialty":null,"InviteeType":
I want to use ActivityId":6216 which I correlated. But I want use it only if CId has data. If CId is null, I need to skip it.
This is ForEach Controller configuration:
Could someone please help me to figure out how to skip rows which have null in CId column?

If your Regular Expression Extractor won't allow null values, it will ignore activity Ids with null CId.
This work for me with your given text for ignoring null in CId column:
ActivityId":(\d+)([^\t\n]+)CId":"

Use the IF controller and in that put the condition as ${__jexl3("${CId}"!= null,)}
And then if your CId is not null then that row should be picked up.!!
I am considering that your data is coming from an external source like csv file or so..!!

For every line you can do this:
if line =~ /.*?CId["]:"?[0-9]+"?.*/; puts line end

Related

How to get records where column is not empty or null in laravel?

This is my table:
This is my code I tried:
$socials = SocialIcon::whereNotNull('link')->get()->all();
$socials = SocialIcon::whereNotNull('link')->get();
I want to get all records where column link is not empty.
First you have to understand the difference between NULL and an empty string. NULL is the absence of a value and no memory is allocated for NULL. But empty string is a value with value stored in the memory as "". From your db I can see you have an empty string as a value for the last row in link column. If the value is NULL then you will find NULL is written in the field.
Now as you want to check both NULL and empty you should write it like
$socials = SocialIcon::whereNotNull('link')->orWhere('link','<>','')->get();
this query will both check for NULL and empty value and will return rows with not NULL and empty link value.
Considering a value as NULL same as empty string is not correct. Both are not same.
You can use the below code:
$socials = SocialIcon::where(function($q) {
$q->whereNotNull('link')->orWhere('link','<>','');
})->get();
The resulted query running on DB will be:
select * from social_icons where (link is not null or link <> "")
If you wish to learn more about the Laravel's query builder, click here
You can simply do this
$socials = SocialIcon::where('link', '<>', '')->get();
Read this: https://laravel.com/docs/7.x/queries#where-clauses
Following will also do the job.
$socials = SocialIcon::all();
And then in your template for second case:
#foreach($socials as $social)
#if(!empty($social->link))
your content here
#endif
#endforeach

How to get table name for a simple Sequel Dataset object?

Ie, given a dataset object ds = DB[:transactions].where{updated_at > 1.day.ago} - no funny joins and stuff going on - how could I fetch the table name (:transactions) ?
If you want the first table in the dataset, you can use ds.first_source.
If you want it as a string you can do:
ds.first_source_table.to_s
If you want a symbol, just omit .to_s
Based on the example provided, I would do something like this.
ds.klass.name
That will return a string with the name of your table.

LINQ Check for Nulls with OR

I have 2 values in table User: Address1, Address2. Both could be null. As part of a filter method, I am attempting something like the below:
var tempUsers = users.Where(q => q.Address1.ToLower().Contains(address.ToLower()) || q.Address2.ToLower().Contains(address.ToLower()));
This is returning a Null Reference Exception, and rightly so.
Linq queries need to be handled against null values
I would be attempting
null.ToLower() and null.Contains() within the query
What is the best way to go around it? If it was a simple 1 field Query, for e.g. just Address1, I would have simply filtered out all items with empty Address1, and continued normally in the second query. In this case, both fields are important to the filtering, as in, the input: address could be either in Address1 or Address2 of the User table.
I know this might not be possible in a 1 liner, but what is the best approach to take in terms of time and performance?
How about this:
var address = (GetAddressFromOuterWorld() ?? String.Empty).ToLower();
var tempUsers = users.Where(user => (user.Address1 ?? String.Empty).ToLower().Contains(address)
|| (user.Address2 ?? String.Empty).ToLower().Contains(address));
This definitely works with LINQ to Object, but probably fails with LINQ to SQL, but in that case you normally write user.Address1 == address || user.Addrss2 == address and your database uses a case-insensitive collate setting.
You can easily add null checks like this.
var tempUsers = users.Where(q =>
(!string.IsNullOrEmpty(q.Address1) && q.Address1.ToLower().Contains(address.ToLower())) ||
(!string.IsNullOrEmpty(q.Address2) && q.Address2.ToLower().Contains(address.ToLower())));

nifi extracttext from a JSON attribute that is commar delimited

Hi I am fairly new to apache nifi and I need to extract a suburb from a json string
flowfile looks like this
\/
{"UserName:"John Doe", "Address":"22 smith st, Smithville, NSW","IP":"10.10.10.1}
The suburb is always the 2nd last value in the commar delimited list of the "address" attribute. Sometime it wont be in the 2nd position from left as there might be something like
{"UserName:"John Doe", "Address":"Level 10, 22 smith st, Smithville, NSW","IP":"10.10.10.1}
I have tried to use extract text with regex [^,]+(?=,[^,]*$)
but was not able to make it extract the attribute correctly.
I think you haven't use extractText for extract the Json values and it is not proper way to do it.
You can EvaluateJsonPath processor for extract "Address" of the Json attribute with help of following configurations.
Just configure those attributes for destination to be "flowfile-content" and Return Type to be "Json".
Now you have to add new property named "Address":$.Address.
Here you can receive address of json will be stored in attribute named "Address" then you can extract 2nd column of the suburb present in Address like ${Address:substringBeforeLast(','):substringAfterLast(',')}.
Look at this expression guide which may useful for you.
https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#substringafterlast
https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#substringbeforelast

ArangoDB IS_DATE AQL Function

I have a number of items in a collection that have a dateDue field on them. Some have this dateDue field set to an ISO8601 date, and others have null, and some others have a blank string. I want to do the following:
filter DATE_COMPARE(DATE_NOW(), dateDue, "years", "days")
However, if dateDue is null or a blank string this throws an error. I can add this to solve it:
filter w.dateDue != null and w.dateDue != ""
filter DATE_COMPARE(DATE_NOW(), dateDue, "years", "days")
But that only covers null values and blank strings. Sure this may be enough, but I would like to ensure that any record that does not have a valid date for the dateDue field is excluded. I was expecting to see an IS_DATE function for Arango, but I couldn't find one in the manual anywhere. Any ideas?
There is currently no IS_DATE function or something similar in AQL, so using filters as above is definitely one way to do it.
To make it a bit easier in the future, an IS_DATESTRING AQL function has been added in the 2.8 branch today. This will allow writing the filter as follows:
FILTER IS_DATESTRING(w.dateDue)
FILTER DATE_COMPARE(DATE_NOW(), w.dateDue, "years", "days")

Resources