Event table delete operation exception in wso2 cep 3.1.0 - exception

I am learning to use event table in the cep , but there was a mistake.
from StreamInstance[action contains 'add']#window.length(1)
select *
insert into StreamInstanceTable;
from StreamInstance[action contains 'delete']
delete StreamInstanceTable
on StreamInstanceTable.streamName == StreamInstance.streamName;
when delete the data from StreamInstanceTable, If I take the conditions (on) will be wrong, if not with the condition is right.
[2014-10-23 17:40:28,674] INFO - {RedisListener} recving mesage:{"log": "StreamInstanceTemplateName","streamName": "stream1","moduleCount"
: "4","ip": "127.0.0.1","pid": "1001","from": "container","gid": "gid100","action":"delete"}
[2014-10-23 17:40:28,678] ERROR - {EventJunction} Error while dispatching events
java.lang.ArrayIndexOutOfBoundsException: -1
at org.wso2.siddhi.core.event.StateEvent.getStreamEvent(StateEvent.java:51)
at org.wso2.siddhi.core.executor.expression.VariableExpressionExecutor.execute(VariableExpressionExecutor.java:151)
at org.wso2.siddhi.core.executor.conditon.compare.CompareConditionExecutor.execute(CompareConditionExecutor.java:48)
at org.wso2.siddhi.core.table.InMemoryEventTable.delete(InMemoryEventTable.java:82)
at org.wso2.siddhi.core.query.output.callback.DeleteTableCallback.send(DeleteTableCallback.java:36)
at org.wso2.siddhi.core.query.output.ratelimit.OutputRateManager.sendToCallBacks(OutputRateManager.java:38)
at org.wso2.siddhi.core.query.output.ratelimit.PassThroughOutputRateManager.send(PassThroughOutputRateManager.java:26)
at org.wso2.siddhi.core.query.selector.QuerySelector.process(QuerySelector.java:221)
at org.wso2.siddhi.core.query.processor.handler.SimpleHandlerProcessor.processHandler(SimpleHandlerProcessor.java:149)
at org.wso2.siddhi.core.query.processor.handler.SimpleHandlerProcessor.receive(SimpleHandlerProcessor.java:77)
at org.wso2.siddhi.core.stream.StreamJunction.send(StreamJunction.java:45)
at org.wso2.siddhi.core.stream.input.InputHandler.send(InputHandler.java:41)
at org.wso2.carbon.event.processor.core.internal.listener.SiddhiInputEventDispatcher.sendEvent(SiddhiInputEventDispatcher.java:107)
at org.wso2.carbon.event.processor.core.internal.listener.SiddhiInputEventDispatcher.consumeEventData(SiddhiInputEventDispatcher.jav
a:95)

Can you try the below query, there seems to be known issue (Don't use the stream definition name as prefix)
from StreamInstance[action contains 'delete']
delete StreamInstanceTable
on StreamInstanceTable.streamName == streamName;

Related

non-string key Missing field in Couchbase

For migration I have used the following couchbase query
INSERT INTO `bucket`
(KEY _k, VALUE _v, OPTIONS {"expiration": ttl})
SELECT REPLACE(META().id, "2_", "3_", 1) _K, META(_v).expiration AS ttl
from `bucket` _v
where _v._class="classname"
AND META().id LIKE "2_%";
While running getting the following error
{
"code": 5070,
"msg": "Cannot INSERT non-string key Missing field or index _k. of type value.missingValue."
}
The problem was different cases(lower and upper) used in different places. changing _k to small case solved the problem.

How to use '$' special character in Athena SQL DML referencing Queries?

I have data coming to s3 from mixpanel and mixpanel adds '$' character before some event properties. Sample:
"event": "$ae_session",
"properties": {
"time": 1646816604,
"distinct_id": "622367f395dd06c26f311c46",
"$ae_session_length": 17.2,
"$app_build_number": "172",
"$app_release": "172",...}
As '$' special character is not supported in Athena I need to use some sort of escape thing to proceeds from here. I would really need any help regarding this.
The error i am getting in subsequent DML queries after My DDL table:
HIVE_METASTORE_ERROR: Error: name expected at the position 262 of
'struct<distinct_id:string,
sheetid:string,
addedUserId:string,
memberId:string,
communityId:string,
businessId:string,
time:timestamp,
communityBusinessType:string,
initialBusinessType:string,
sheetRowIndex:string,
dataType:varchar(50),
screenType:varchar(50),
rowIndex:int,
$ae_session_length:int>' but '$' is found.
(Service: null; Status Code: 0; Error Code: null; Request ID: null; Proxy: null)
Since, I can not change the column names as they are directly populating from mixpanel on daily interval I really think that there should be work around this somehow!

Doing a search with Where and possibly all in rails

I'm working on a rails project that has two models - incoming_purchases and item_instances. An incoming purchase has many item_instances and an item_instance belongs to an incoming purchase. My problem is that I want to show all orders that have been received and to do this, each item_instance has to be received off the order. The item_instance model has a date_received column. So I can have an order, lets call 1.
Order 1: has two item instances where one of the items has been received:
item 1: date_received: 9/15/20
item 2: date_recieved: nil
I need to show records where ever value of date received is filled in order for the order to be received. Thus, the example above would not be received. So far, I have a scope written that looks like this:
scope :search_for_received_orders, ->{ joins(:item_instances).where.not('item_instances.date_received': [nil] ).distinct }
This would get me the example above which would be a partially filled order. My code to see NOT received orders WORKS and is this:
scope :search_for_not_received_orders, ->{ joins(:item_instances).where('item_instances.date_received': [nil, ""] ).distinct }
Basically, I need to ensure for a received order that ALL Item Instances have a date in the date_received column. I cannot figure this out. Thank you for any help.
Error I'm getting with first response below:
/home/mcuddy/learn/inventory/src/inventory/app/models/incoming_purchase.rb:23: syntax error, unexpected '}', expecting => ...nces: {!date_received.present?})} ... ^
/home/mcuddy/learn/inventory/src/inventory/app/models/incoming_purchase.rb:36: syntax error, unexpected do (for lambda) item_instances.each do |i| ^~
/home/mcuddy/learn/inventory/src/inventory/app/models/incoming_purchase.rb:40: syntax error, unexpected end, expecting '}' end ^~~
scope :received_orders, -> { includes(:item_instances).where.not(item_instances: {!date_received.present?})}
Try this:
scope :received_orders, -> { includes(:item_instances).where.not(item_instances: {date_received: nil})}
scope :not_received_orders, -> { includes(:item_instances).where(item_instances: {date_received: nil})}
Received orders don't have any item instance with date_received nil.
Not received orders have at least 1 item instance with date_received nil
Try following, also ref this for how to use where condition
scope :search_for_received_orders,
->{ joins(:item_instances)
.where.not('item_instances.date_received': nil).distinct }
scope :search_for_not_received_orders,
->{ joins(:item_instances)
.where("item_instances.date_received IS NULL OR item_instances.date_received = ''"}).distinct }

Laravel, delete a queue job by user id

Each time a user is created or updated, an email will be send when some timestamp is reached.
I control this by queues. Each queue is stored in the "jobs" table.
That table has a column called "payload" which is a json with all the info of that job. In my case, a payload of this is like this one:
{
"job":"Illuminate\\Queue\\CallQueuedHandler#call",
"data":{
"commandName":"Illuminate\\Mail\\SendQueuedMailable",
"command":"O:34:\"Illuminate\\Mail\\SendQueuedMailable\":1:{s:11:\"\u0000*\u0000mailable\";O:16:\"App\\Mail\\Expired\":16:{s:7:\"\u0000*\u0000user\";O:45:\"Illuminate\\Contracts\\Database\\ModelIdentifier\":2:{s:5:\"class\";s:8:\"App\\User\";s:2:\"id\";i:1020;}s:4:\"from\";a:0:{}s:2:\"to\";a:1:{i:0;a:2:{s:7:\"address\";s:24:\" example#gmail.com\"\";s:4:\"name\";N;}}s:2:\"cc\";a:0:{}s:3:\"bcc\";a:0:{}s:7:\"replyTo\";a:0:{}s:7:\"subject\";N;s:4:\"view\";N;s:8:\"textView\";N;s:8:\"viewData\";a:0:{}s:11:\"attachments\";a:0:{}s:14:\"rawAttachments\";a:0:{}s:9:\"callbacks\";a:0:{}s:10:\"connection\";N;s:5:\"queue\";N;s:5:\"delay\";N;}}"
}
}
As you can see, there job is associated with: App\\User\";s:2:\"id\";i:1020
How could I remove that job from the table, by that user id? I could get all the data with DB::table('jobs) and loop until I found the id inside payload and delete it, but is there any helper or function of Laravel to do that?
You can json_decode the payload and unserialize the $payload['data']['command']
$job = DB::table('jobs')->whereId($id)->first();
$payload = json_decode($job->payload);
$mailable = unserialize($payload['data']['command']);
if ($mailable->user->id != GOOD)
DB::table('jobs')->whereId($id)->delete();
hope this helps

What is the json body in post request in order to fetch all rows from an operation list with key?

I have defined a list for operational data in yang model as:
list listener-state {
key “listener-name”;
config false;
description
“common statistics for given listener (i.e sent messages)”;
uses listener-state-info;
…
}
I use opendaylight api (org.opendaylight.yangtools.yang.data.codec.gson.JsonParserStream) which will convert the json body in request to org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode, in order to finally generate the XML rpc for confd server.
In my case, I want to fetch all rows from this operation list, then I try to make the json as :
“command”: {“service” : {“server” : {“listener-state” : {}}}},
I will get exception that : “Input is missing some of the keys of listener-state”
Then I can add the key value to the json body :
“command”: {“service” : {“server” : {“listener-state” : {“listener-name”: “first”}}}},
This case, I can only get one row. I also try to leave the key value as blank:
“command”: {“service” : {“server” : {“listener-state” : {“listener-name”: “”}}}},
Then the response will be all key values instead of all rows. So now my question is what the json will be in order to get all rows in the list without knowing the key values ?
This should be feasible since I figure out XML request can do that. But I can't figure out what the matching json will be.
Thanks.
I did bunch of investigation. Unfortunately, I don't think there is a way to fetch the whole table