Reserved column identifiers in Java data source library?

20 views
Skip to first unread message

Robert Brewer

unread,
Sep 30, 2009, 2:36:13 AM9/30/09
to Google Visualization API
I'm writing a data source using the Google Java data source library. I
have run into a strange problem with column identifiers. My data table
consists of a column of DATETIME values, followed by two columns of
NUMBER values. If the identifier for the DATETIME column is
"timestamp", "timeStamp", "dateTime" and a few other things I tried,
any select query I make using that column identifier returns a big
error message. The raw JSON output is reproduced below (hopefully
Google Groups doesn't mangle it):

google.visualization.Query.setResponse
({version:'0.6',status:'error',errors:
[{reason:'invalid_query',message:'Invalid
query',detailed_message:'Query error: Encountered \u0022 \u0022,\u0022
\u0022, \u0022\u0022 at line 1, column 16.\nWas expecting one of:\n
\u003cSTRING_LITERAL\u003e ...\n \u003cSTRING_LITERAL\u003e ...
\n \u003cSTRING_LITERAL\u003e ...\n \u003cSTRING_LITERAL
\u003e ...\n \u003cSTRING_LITERAL\u003e ...\n
\u003cSTRING_LITERAL\u003e ...\n \u003cSTRING_LITERAL\u003e ...
\n \u003cSTRING_LITERAL\u003e ...\n \u003cSTRING_LITERAL
\u003e ...\n \u003cSTRING_LITERAL\u003e ...\n
\u003cSTRING_LITERAL\u003e ...\n \u003cSTRING_LITERAL\u003e ...
\n \u003cSTRING_LITERAL\u003e ...\n \u003cSTRING_LITERAL
\u003e ...\n \u003cSTRING_LITERAL\u003e ...\n
\u003cSTRING_LITERAL\u003e ...\n \u003cSTRING_LITERAL\u003e ...
\n \u003cSTRING_LITERAL\u003e ...\n \u003cSTRING_LITERAL
\u003e ...\n \u003cSTRING_LITERAL\u003e ...\n
\u003cSTRING_LITERAL\u003e ...\n \u003cSTRING_LITERAL\u003e ...
\n \u003cSTRING_LITERAL\u003e ...\n \u003cSTRING_LITERAL
\u003e ...\n \u003cSTRING_LITERAL\u003e ...\n
\u003cSTRING_LITERAL\u003e ...\n \u003cSTRING_LITERAL\u003e ...
\n \u003cSTRING_LITERAL\u003e ...\n \u003cSTRING_LITERAL
\u003e ...\n \u003cSTRING_LITERAL\u003e ...\n
\u003cSTRING_LITERAL\u003e ...\n \u003cSTRING_LITERAL\u003e ...
\n \u003cSTRING_LITERAL\u003e ...\n '}]});

If use "foo", "thyme", or "dayte" or other identifiers for that
column, everything works fine. Are there are some reserved identifiers
that we should avoid using, or is this just a bug? It's easy enough to
work around this problem by picking another name, but the above error
message doesn't exactly scream out 'change your identifier name'. If
there are reserved identifiers we should avoid, a list of them would
be nice.

I should mention that I'm quite the Javascript newbie, so if this is
something that should be obvious if you know Javascript, then I
apologize. However, this processing is happening inside the Java
library before it even gets interpreted by the browser, so I'm not
sure how Javascript would come into the picture.

Mahalo!

--
Robert Brewer http://excitedcuriosity.wordpress.com
PhD Student, University of Hawaii at Manoa, Computer Science Dept
Research Assistant in Renewable Energy and Island Sustainability
http://reis.manoa.hawaii.edu

Markw65

unread,
Sep 30, 2009, 10:13:47 AM9/30/09
to Google Visualization API
There are many reserved identifiers in the google query language. If
you want to use one of them as the name of a field, you have to quote
it with backticks in your queries: `datetime`, for example. But better
to just avoid them, in my opinion...

Mark

Robert Brewer

unread,
Sep 30, 2009, 10:06:28 PM9/30/09
to Google Visualization API
On Sep 30, 4:13 am, Markw65 <mark...@gmail.com> wrote:
> There are many reserved identifiers in the google query language. If
> you want to use one of them as the name of a field, you have to quote
> it with backticks in your queries: `datetime`, for example. But better
> to just avoid them, in my opinion...
>
> Mark

I see that I needed to RTFM. I never made it to the bottom of the
query language reference web page, which has a clearly labeled list of
reserved words, of which "timestamp" is one:

http://code.google.com/apis/visualization/documentation/querylanguage.html#Reserved_Words

My bad. Still, I think an error message like "reserved word used as
column identifier" would be appropriate, rather than many lines of
gobbledegook.
Reply all
Reply to author
Forward
0 new messages