0

I would like to know if WSO2 Data Analytics Server allows to define a dynamic events tables or dynamic streams. For example, imagine one event represent a car, and in this event, an attribute is the 'brand' of the car (Ford, Mercedes, Audi ...).

And I would like to add a column each time there is a new different brand. So my table would look like this :

enter image description here

And thus, if I receive an event with the brand 'Toyota', it would add a column to my table which would look like this:

enter image description here

Considering that I don't know in advance the number of different brands I will receive, I need this to be dynamic.

Community
  • 1
  • 1
wolfyiy
  • 13
  • 4

1 Answers1

0

Dynamically changing the schema of an event table is not possible. This is because the schema of the event table is defined when the Siddhi execution plan is deployed. Once it is deployed, the schema cannot be changed.

On the other hand, it looks like what you need here is not an event table.

Perhaps, what you need to do is to update the schema of a table (an RDBMS table) when a certain event happens (for example, when a car event arrives with a new brand). Do you use this updated table in your Siddhi execution plan? If you do not use it, then you do not need an event table. Please correct me if I have misunderstood your requirement.

If your requirement is to update the schema of a table when a certain event happens, then you might need to write a custom event publisher to do that. If so, please refer the document on the same: Building Custom Event Publishers.

Dilini
  • 777
  • 8
  • 22
  • Yes, what I want to do is update the schema of a table when a certain event arrives, can I do this using a RDBMS table ? Because I know that mySQL allows to add column to a table but there is no request with SiddhiQL to do this so why a RDBMS table would help me in this case ? According that I receive this kind of events : id, brand, consumption, nbPlace --> 1, Ford, 5.0, 5 --> 2, Toyota, 4.0, 5 And with this events, I want to display the table on the image above with the consumption in the correct cell according to the brand and the id. – wolfyiy Jul 13 '17 at 08:02
  • Thank you for your information concerning the custom Event Publisher, but publisher is just to publish event received from a stream, but I probably can't do the logical part in the publisher. Sorry, I misunderstood your question « Do you use this updated table in your siddhi execution plan ? », which table you talking about ? – wolfyiy Jul 13 '17 at 08:14
  • I see...so not only you need to change schema but also you need to insert data into that table also. This is not possible with Siddhi. – Dilini Jul 13 '17 at 15:05
  • Cannot you make the `brand` a column (so this column will contain values such as Ford, Toyota...etc)? It sounds a bit strange when you create new columns when new data come in.. Cannot you achieve your requirement with a static table having columns: id, brand, consumption, nbPlace ? – Dilini Jul 13 '17 at 15:08
  • In fact, the brand of the car was an simple example to easily explain what I was looking for, but my real case is much more complicated. Here is a picture with a more relevant example, I need in fact to display this kind of table but how I don’t know how many different ‘characteristics’ I will receive at the end, I can’t define an event table with a fixed number of parameters in advance. [The more relevant example picture](https://snag.gy/5P4nbg.jpg) – wolfyiy Jul 14 '17 at 13:08
  • If siddhi don’t allow me to add rows and columns when events are received, maybe I can count the number different ‘characteristics’ in a first time (or brands for the first example) and in a second time, at the end, when I have the final number, I define my table with this number of parameters. So, in a first execution plan, I count the number and in a second execution plan I define a table with this number of parameters. Do you know if it is possible ? I didn’t see things like that in WSO2 das documentation… (PS: I would like to thank you so much for the time you spent to answer to me !) – wolfyiy Jul 14 '17 at 13:08