Vertica

Fun with Vertica UDX

During a week in July, Vertica held a competition for all of us, the 2012 summer interns. We had a week to write a user defined function for Vertica. We could work individually or in teams of two, and the function could do whatever we wanted it to do. We were, however, told that we would be judged by a range of people from across the company on criteria that was never quite explained to us.

Like most people, and probably many Vertica customers, I had never written a UDX for Vertica before. I was already in the middle of my normal summer work, and did not necessarily relish the idea of putting off my other tasks, which I was enjoying, to learn a new skill that seemed very specific. I was still not sure what exactly a UDX was, but writing one sounded difficult and unpleasant.

So, being the natural procrastinator that I am, I put the competition off. Unfortunately for me, this summer Vertica has an odd number of engineering interns and my fellow interns did not seem as daunted as I was. In the time that I spent pretending that the competition was not actually occurring, they had already divided into teams and started working on their ideas. The final presentation was a mere couple days away, and I needed an idea quickly. Because I also was now apparently working alone, I needed that idea to be easy to implement.

At the company pizza lunch that day, one of the many perks of working for Vertica, I tried to pick the brain of my fellow coworkers. “What would you make if you were me?” I asked them. Lyric jokingly suggested that I make something to order pizza for everyone listed in a database. Although that would have been amusing, I had visions of a computer calling a local pizza place and placing an order using some sort of text to speech program. I settled, however, for something much simpler: a UDX to send email from Vertica.

I was excited; my UDX had lots of potential uses. Many companies collect statistics of their customers and then want to send promotional emails out to certain demographics. After I pitched my idea, Lyric nicknamed me the Spam Artist. “But this could even save lives!” I thought. What if the National Weather Service harnessed the speed of Vertica to warn people of an impending tornado by using combining their projected storm paths with Vertica’s new Geospacial features!

The only problem was that I still didn’t know how to write a UDX. I decided that I would write my program in standard C++ and then begin the arduous process of turning my code into a UDX. Luckily, I was in for a big surprise. Writing a UDX for Vertica turned out to be really simple! I quickly found a UDX on the Vertica Github community site that was similar to the one that I was trying to write. I realized that with a few calls to a reader and writer and a library wrapper class, my UDX was ready to go. My fear had been misguided; writing a UDX was probably the easiest part of my summer. There were plenty of example UDXs to look at and any questions I had were quickly answered by the Vertica docs.

And as for the presentation, that was an entirely different animal. When smart, creative engineers decide to hold a competition, I guess it involves live judging with an olympic style scoring system projected onto the front of the room for all to see. It was pretty intense, but I walked away with a Kindle for my efforts :).

Leave a Reply

Get Started With Vertica Today

Subscribe to Vertica