Click here to Skip to main content
15,867,835 members
Articles / Programming Languages / SQL
Tip/Trick

SQL Query Tool for Google Fusion Tables

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
6 Mar 2016GPL33 min read 16.6K  
A Google fusion tables SQL front end for quick query hacks. Comes with code completion, syntax and error highlighting plus some extra commands like DROP TABLE. Antlr4 grammar included.

Introduction

If you're searching a no-charge zero-administration online database which supports some sort of query language and you can live without acid transactions, you might end up with Google fusion tables (gft) - as happened to me.

The next thing I discovered was that the SQL on offer is somewhat peculiar, though it supports geo conditions. And the only front end I could find to try some things was the API explorer, where you have a single line three inches wide text field for your queries, and you get JSON in return, once you got them right.

That's not so handy, so I created a minimalist query console to allow the use of human readable table names instead of table IDs. Starting with some small steps, I got curious about Antrl4 and ended with support for augmented SQL, syntax highlighting and code completion. Recently, I put the core functionality into an Eclipse-Plugin.

Find a detailed description and jar/code downloads at the project page. The client looks roughly like this now:

Image 1

To make hands on work easier, I added support for DROP and ALTER TABLE (for rename table) statements, and copy table, in the CREATE TABLE ... AS SELECT form. Recently, I also augmented UPDATE and DELETE, it offers the same conditions in the WHERE clause like you have in SELECT. The client breaks it up into one select to get the rowids and one delete or update query for each of them.

Using the Code

Image 2 It's a set of Maven/Eclipse(Mars) projects which builds as is.

You might find the connector interface with the implementation for the fusion tables Java API useful. The other part is the gft Antlr4 grammar and the related Java classes. If someone feels like doing similar things, I'd be willing to polish up the bash scripts I used for generating the Java classes and running the test rig.

Points of Interest

I'm not a Google evangelist, but the scope of the tool was suitable to get my feet wet with Antlr parsing and some approach to code completion.

Antlr4 turned out to be an excellent tool which makes the job as comfortable as it can possibly become. In this case, all I ever had to touch was the grammar file and the generated Java listener class. I'd think, worries about creating a domain specific language in this way aren't justified any more. There are even more elaborate tools out there for free, some based on Antlr itself.

Robert Futrell's RSyntaxTextArea component for the editor, coming with AutoCompletion, was eventually OK since it kept the resource footprint to a minimum. Eventually, the Eclipse plug-in approach seems more useful to me, but creating a first version without all the Eclipse complexities made it much easier to find my way around there.

The Google Fusion Tables ServiceTM is remarkably limited in its usage quotas, you won't get much beyond toy applications. Find some data about it at the project page.

History

  • 30th January, 2016: Initial version
  • 6th February, 2016: Covered additional features
  • 20th November, 2016: Eclipse plug-in

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Austria Austria
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --