How to select a value from a list with jq - jq

I have a list of strings of tags related to a docker image.
The array looks like this:
["latest", "SOME_SHA"]
I cannot figure out how to select the value from the list that is not "latest".
I tried to use jq ´ select(. != "latest"´) but this returns the entire array, and not just the "SOME_SHA" value

To select all values not equal to a specific $value, you could use map(select(. != $value)); to select the first such value, if any, you could write:
first(.[]|select(. != $value))

Related

Replacing empty string column with null in Kusto

How do I replace empty (non null) column of string datatype with null value?
So say the following query returns non zero recordset:-
mytable | where mycol == ""
Now these are the rows with mycol containing empty strings. I want to replace these with nulls. Now, from what I have read in the kusto documentation we have datatype specific null literals such as int(null),datetime(null),guid(null) etc. But there is no string(null). The closest to string is guid, but when I use it in the following manner, I get an error:-
mytable | where mycol == "" | extend test = translate(mycol,guid(null))
The error:-
translate(): argument #0 must be string literal
So what is the way out then?
Update:-
datatable(n:int,s:string)
[
10,"hello",
10,"",
11,"world",
11,"",
12,""
]
| summarize myset=make_set(s) by n
If you execute this, you can see that empty strings are being considered as part of sets. I don't want this, no such empty strings should be part of my array. But at the same time I don't want to lose value of n, and this is exactly what will happen if I if I use isnotempty function. So in the following example, you can see that the row where n=12 is not returned, there is no need to skip n=12, one could always get an empty array:-
datatable(n:int,s:string)
[
10,"hello",
10,"",
11,"world",
11,"",
12,""
]
| where isnotempty(s)
| summarize myset=make_set(s) by n
There's currently no support for null values for the string datatype: https://learn.microsoft.com/en-us/azure/kusto/query/scalar-data-types/null-values
I'm pretty certain that in itself, that shouldn't block you from reaching your end goal, but that goal isn't currently clear.
[update based on your update:]
datatable(n:int,s:string)
[
10,"hello",
10,"",
11,"world",
11,"",
12,""
]
| summarize make_set(todynamic(s)) by n

REGEXP_SUBSTR return all matches (mariaDB)

I need to get all the matches of a regular expression in a text field in a MariaDB table. As far as I know REGEXP_SUBSTR is the way to go to get the value of the match of a regular expression in a text field, but it always returns after the first match and I would like to get all matches.
Is there any way to do this in MariaDB?
An example of the content of the text field would be:
#Generation {
// 1
True =>
`CP?:24658` <= `CPV?:24658=57186`;
//`CP?23432:24658` <= `CPV?:24658=57186`
// 2
`CP?:24658` <> `CPV?:24658=57178` =>
`CP?:24656` <> `CPV?:24656=57169`;
And the select expression that I'm using right now is:
select REGEXP_SUBSTR(textfield,'CP\\?(?:\\d*:)*24658') as my_match
from table
where id = 1243;
Which at the moment returns just the first match:
CP?:24658
And I would like it to return all matches:
CP?:24658
CP?23432:24658
CP?:24658
Use just REGEXP to find the interesting rows. Put those into a temp table
Repeatedly process the temp table -- but remove the SUBSTR as you use it.
What will you be doing with each substr? Maybe that will help us devise a better approach.

how to search for a particular string in the given string in oracle

I have a string with value as '12A,12B,12C,13,14'.
I want to check whether '2A' is available in the above string.
while trying my value '2A' checks in 12A and returns as matched.
Please give me a solution for this.
You can do something like this:
select * from table where ',' || col || ',' like '%,2A,%';
Commas are concatenated to the column to cover the cases where the element is present at the start or end of the string.

find records in model looking non primary columns

Im trying to make a query in asp.net models.
Im understand we can get a record by a primary key with ModelContext.Table.Find(id), and a list of all items with ModelContext.Table.ToList()...
My question is, how i can get a single item and entire list of items looking in another columns? for example name and lastname.
Something like ModelContext.Table.Find(new {name = "Stefan", lastname = "Luv"}) and ModelContext.Table.FindAll(new {"country"="usa"})
Thanks.
Use Where:
ModelContext.Table.Where(item => item.lastname == "Luv" && item.name == "stefan").ToList();
This is a specific example but you can of course set many kinds of predicates in the where expression.
If you want a single unique item, you can use Single():
ModelContext.Table.Single(item => item.lastname == "Luv" && item.name == "stefan");
Note this will throw an exception in case there is more than one row that satisfies your predicate.

pl sql decode function for use to check two values

In the select statement i need to return a value based on the data on other two colomns. For example,
select clarify, clarify_rece_date, clarify_process_date
from test_db;
So the clarify should return yes if both clarify_rece_date and clarify_process_date is not null and if they null clarify should return No.
I could have use decode here if i want to check only onle column as below,
select decode(clarify_rece_date, null,'Yes','No') clarify, clarify_rece_date, clarify_process_date
from test_db;
But how can i check for both columns in this scenario?
You could have a rather complex DECODE. However, it would make far more sense to use a CASE statement
SELECT (CASE WHEN clarify_rece_date IS NOT NULL AND
clarify_process_date IS NOT NULL
THEN 'Yes'
ELSE 'No'
END) clarify,
clarify_rece_date,
clarify_process_date
FROM test_db

Resources