regexp_substring cannot be cast to scala.Function2 - scala

case when lower(description) like '%route of administration%' then text_answer
when mnemonic is not null then regexp_substr(lower(mnemonic),'(oral|topical|otic|rectal|nasal|vaginal|(inhalat|intra|subcut|transd|ophth)[a-z]+)')
else null
end as localroute
while executing the above am getting error as
java.lang.ClassCastException:
com.optum.cdr.fe.utils.UDFs.regexp_substring$$anonfun$1 cannot be cast
to scala.Function2

Related

Confusion with Null safety

I'm pretty new to flutter and because of the null safety feature I've been getting a lot of errors from a code that will run perfectly fine in Java or other langs. For example this-
int ? i;
var icecreamFlavours = ['chocolate', 'vanilla', 'orange'];
icecreamFlavours.forEach((item) {
i++; //This is where I get the error
print('We have the $item flavour');
});
My Error Message
Error: Operator '+' cannot be called on 'int?' because it is potentially null.
i++;
Error: A value of type 'num' can't be assigned to a variable of type 'int?'.
i++;
You can't do either i++ or i+=1 on a nullable variable, because the reason is simple, null variable can have null values which will make increment no sense.
In addition to this, you can't even do i!++ or i!+=1 even if you are sure that i is not null. There is an open issue for this https://github.com/dart-lang/language/issues/1113
So for now you can do this i = i! + 1
Update:
For i = i! + 1 to work you need to be sure about i not being null. So it's better to initialise/assign i with some value before using it.

Flutter how to test if ui.Image is empty or null correctly?

I define globally a variable as ui.Image _img1Global = null as ui.Image; then I wanted to check to determine if the value is null or not.
if (_img1Global != null as ui.Image) {
canvasWrapper.save();
canvasWrapper.drawImage(
_img1Global, Offset(x, y - 2), new Paint());
canvasWrapper.restore();
}
I want to check if it is not null then I want to operate the drawImage but I keep getting error as type 'Null' is not a subtype of type 'Image' in type cast at this if statement ? How to check if its filled with ui.Image and check its correct type?
I have even try this
_img1Global != null as ui.Image
? print("is null")
: print("is not null");
still I am getting same error ?
null as ui.Image
It is throwing an error because the above code is telling that set null type as an Image type
To check the type of a variable use the runtimeType operator
if (_img1Global.runtimeType == Image) print('True')

Promela: Errors with parameters in proctypes, and using 'end' label

I'm new to Promela, and I'm not sure what the issue with my code is:
proctype frogJump(int frogNum, int frogDirection)
{
printf("FROG%d STARTS AT %d", frogNum, frogs[frogNum]);
int temp;
end: do
:: lock(mutex) ->
if
::(frog[0] == frogs[frogNum]+frogDirection || frog[0] == frogs[frogNum]+frogDirection+frogDirection]) ->
temp = frog[frogNum];
frog[frogNum] = frog[0];
frog[0] = temp;
printCurrentLayout();
printf("FROG%d FROM %d TO %d", frogNum, temp, frog[frogNum]);
:: else -> unlock(mutex);
fi;
:: skip;
od
}
Getting the following errors:
spin: frogs.pml:25, Error: syntax error saw 'data typename' near 'int'
spin: frogs.pml:30, Error: syntax error saw 'an identifier' near 'end'
With line 25 being
proctype frogJump(int frogNum, int frogDirection)
and line 30 being
end: do
As far as I understand, I'm supposed to use the 'end' label to signal to SPIN that the frog proctype can be considered ended without having to be at the end of it's code. But I'm having the issue that I can't seem to use 'do' beside the 'end' label. I also don't know what the issue with the parameter 'int' is.
This error
spin: frogs.pml:25, Error: syntax error saw 'data typename' near 'int'
is caused by the fact that the argument list separator for a proctype declaration is ; and not ,.
You can make the error go away by changing
proctype frogJump(int frogNum, int frogDirection)
into this
proctype frogJump(int frogNum; int frogDirection)
In the case of inline functions, the correct argument list separator is indeed ,, e.g.
inline recv(cur_msg, cur_ack, lst_msg, lst_ack)
{
do
:: receiver?cur_msg ->
sender!cur_ack; break /* accept */
:: receiver?lst_msg ->
sender!lst_ack
od;
}
The second error message
spin: frogs.pml:30, Error: syntax error saw 'an identifier' near 'end'
is probably just a side effect of the incorrect parsing tree resulting from the first syntax error, and should fade away accordingly when fixing it.

Update statement throwing error type " " does not exist

I have this simple update statement which is throwing the error below and I can't figure out why.
UPDATE myschema.webhooks SET app_id = NULL WHERE app_id = 'testing';
ERROR: type " " does not exist
LINE 1: ... myschema.webhooks SET app_id = NULL WHERE app_id = 'testing...

Drools. NullPointerException if set field by FactType

I declared the element to insert by .drl syntax:
declare TheElement
myfield:long
end
and I try to set the field in my javacode:
FactType type = base.getFactType(PACKAGE, "TheElement");
Object myObj = type.newInstance();
type.set(myObj , "myfield", 226); //if I comment this line the insert is ok but the field was not set
handle = session.insert(myObj);
session.fireAllRules();
I receive this error:
Exception in thread "main" java.lang.NullPointerException
at org.drools.factmodel.ClassDefinition.set(ClassDefinition.java:232)
at org.rec.Session.notify(Session.java:124)....