Page 1 of 1

Can a UDx communicate back to the DB?

Posted: Tue Oct 13, 2015 8:00 pm
by sarah
Hi guys,

Do you guys know if a UDx (either written in C++, R or Java) can communicate back to Vertica? That is, can the UDx itself connect back to the DB (i.e. using ODBC or JDVC) and get query the DB?

I found in the documentation where it says “The external procedure cannot communicate back to HP Vertica.” in the “Using External Procedures” section of the “Extending HP Vertica” document, but I can’t find any indication that a UDx cannot.

Thank you

Re: Can a UDx communicate back to the DB?

Posted: Tue Oct 13, 2015 8:31 pm
by scutter
Hi Sarah,

I haven’t written a UDx that does that, but my understanding is that a UDx can do anything that you choose to code. You would need to consider if the UDx is running across multiple partitions in parallel and how that would interract with the database.

—Sharon

Re: Can a UDx communicate back to the DB?

Posted: Wed Oct 14, 2015 3:07 am
by sarah
Scutter, thank you for your response!

What do you mean by "...if the UDx is running across multiple partitions in parallel"?

Re: Can a UDx communicate back to the DB?

Posted: Wed Oct 14, 2015 10:35 pm
by scutter
Hi Sarah,

Suppose you create a UDTF and your logic for the UDTF is in the processPartition() method. You probably wouldn’t want a query to the database to occur within processPartition() because that method will be invoked for every partition of data - so potentially many times on each node.

Most UDxs have some form of parallelism, just like any operator that is running within Veritca.

The UDx framework does have a setup() method that is invoked once per instance. That might be a place where a query that only needs to be executed once could be placed. But I am speculating. I’ve written UDxs but they have been of the more typical variety where all they do is process the incoming data and send back a result set.

—Sharon