I need to assign a value to a particular attribute in a stream by checking a condition.
How do I do it?
e.g
if a person's name is 'John' and I need to modify his name into 'Peter' and insert into another stream, how do I do it?
from myStream [name == 'John']
select *
insert into outStream;
define stream myStream (name string, attribute1 int, attribute2 bool);
from myStream [name == 'John'] --This filter matches any event with name equal to 'John'
select "Peter" as name, attribute1, attribute2 --Replaces the current name with 'Peter'
insert into outStream;
Example 1
Input:
{Dilini, 123, true}
Output:
(there'll be no output, since the name doesn't satisfy the condition in the filter, name=='John')
Example 2
Input:
{John, 123, true}
Output:
{Peter, 123, true}
Refer 'Query Projection' capabilities in Siddhi. Check the action: 'Introducing the default value'.
Related
I need function what will return currency type of cell property. Is it possible?
I found only =TYPE(cell) method what return only data type (number, string etc)
there isn't such a function. you will need to try something like:
=INDEX(IFNA(VLOOKUP(REGEXREPLACE(TO_TEXT(A1:A3), "[0-9, ]", ),
{"$", "USD"; "€", "EUR"; "zł", "PLN"}, 2, 0)))
also, you may want to see: https://stackoverflow.com/questions/73767719/locale-differences-in-google-sheets-documentation-missing-pages
what I am trying to accomplish is as follows:
I am trying to have an expression that returns a value "A" if 'apple' is anywhere in the string, and return value "B" if 'bell' is anywhere in the string.
if 'apple' or 'bell' is not in the string, then 'null'
eg, the column will have 'apple', 'bell', 'any other word' at different positions in the string and I need a formula that returns "A" if 'apple' in present and "B" if 'bell' is present
column value example:
'applebee'
'appletart'
'bellview'
'bellmont'
'apple fritter'
'freedom bell'
'bird'
'coffin'
'...'
desired outcome:
"A"
"A"
"B"
"B"
"A"
"B"
"null"
"null"
"null"
i have tried:
[description] contains 'INV' then 1
[description] contains 'VOL' then 2
else 'null'
maybe an if statement could work better?
What happens when you try:
if(lower([description]) contains 'apple') then ('A') else
if (lower([description]) contains 'bell') then ('B') else
(Null)
It would be great to be able to specify a path into a Boost.PropertyTree containing an array.
I can construct a Boost.PropertyTree from this JSON:
const char* theJSONTestText = R"FooArrayTest({
"FooArray": [
{"BarIntValue": 10, "BarString": "some string"},
{"BarIntValue": 99, "BarString": "another string"},
{"BarIntValue": 45, "BarString": "a third string"}
]
})FooArrayTest";
Which is constructed, and prints as expected:
FooArray:
:
BarIntValue: 10
BarString: some string
:
BarIntValue: 99
BarString: another string
:
BarIntValue: 45
BarString: a third string
Of course, the individual elements of the array don't have names.
I know HOW to iterate through the FooArray property, but it would be especially convenient to be able to access individual elements via a JSON dot notation path, like "FooArray[2].BarString", to access a field in the third array element:
std::string theSecondBarString = theParsedTree.get<std::string>("FooArray[2].BarString");
Of course, this throws an exception, because I'm guessing Boost.PropertyTree doesn't know how to handle a path with an array specifier? Or do I have the syntax wrong?
WHY DO I WANT TO DO IT THIS WAY?
I want the client of this PropertyTree to not only be able to GET data from the a specific array element, but also to SET (i.e. change) the data of a specific array element. If there's no straightforward path notation, then the client has to use my invented API functions to first extract then access the desired field, and the reverse to write it back out. That can be tedious and error-prone for tree nodes that contain array elements within array elements.
Incredibly --
This syntax constructs exactly what I'm looking for:
const char* theJSONTestText = R"FooArrayTest({
"SomeArray": {
"[1]": {"BarIntValue": 10, "BarString": "some string"},
"[2]": {"BarIntValue": 99, "BarString": "another string"},
"[3]": {"BarIntValue": 45, "BarString": "a third string"}
}
})FooArrayTest";
...which creates a PropertyTree like this:
DUMP OF parsed JSON:
SomeArray:
[1]:
BarIntValue: 10
BarString: some string
[2]:
BarIntValue: 99
BarString: another string
[3]:
BarIntValue: 45
BarString: a third string
...and allows a syntax such as:
std::string theSecondBarString = theParsedTree.get<std::string>("SomeArray.[2].BarString");
...and -- VOILA:
Second bar string = another string
IMPORTANT: it must be noted that this approach abandons the array notation "[", "]" in the original JSON definition text. Instead, I am simply creating CHILD NODES of SomeArray with the names "[n]". Each child node ([1], [2], [3]) have their OWN child nodes with BarIntValue and BarString. Not what I expected, but it WORKS!
Now I just need to figure out how to construct that PropertyTree using the member functions (vs the raw JSON) and I'm gold!
Is there a function in Coldfusion that will take 2 strings and figure out which is the 'higher' alphabetically . So if I had "Daniel" and "John", it would return Daniel?
Put your strings into an array then use arraySort(). (example not tested)
var names = ['Daniel', 'John'];
arraySort( names, 'textnocase' );
writeOutput(names[1]);
I want to get entries' date for a given month and year, for that I execute successfully in SQliteman the next query:
SELECT date FROM Entries WHERE strftime('%Y-%m',date) = '2013-04'
To use this query with QSqlQuery I use the following code
query.prepare("SELECT date FROM Entries WHERE strftime('%Y-%m',date) = ':year-:month'");
query.bindValue(":month", QString().sprintf("%02d", month));
query.bindValue(":year", QString::number(year));
But the error "Parameter count mismatch" is raised. That is for the quotes in :year and :month, but I have to use it or the query does not return any result.
How must the query be built if the quotes cannot be used?
You cannot replace parameters inside strings; parameters themselves are entire strings.
Concatenate the strings in SQL:
query.prepare("SELECT ... WHERE strftime(...) = :year || '-' || :month");
You could also construct the entire string beforehand:
query.prepare("SELECT ... WHERE strftime(...) = :yyyymm");
query.bindValue(":yyyymm", month + "-" + year);