crate / crate-sample-apps

A JavaScript guestbook app with a number of different backend implementations, each using a different client library to communicate with CrateDB.
Apache License 2.0
66 stars 36 forks source link

Problem with sample app #68

Closed kwthoma closed 6 years ago

kwthoma commented 6 years ago

Get the following error when trying to create the tables for the sample app: SQLActionException[SQLParseException: line 3:5: no viable alternative at input 'user']

This is how it looks in the Crate admin tool, so I'm guessing "user" is a reserved word. Initially got the error when trying to load the schema via crash.

This is the portion of the code from sql/schema.sql that I pasted into the admin console: CREATE TABLE guestbook.posts ( id STRING PRIMARY KEY, USER OBJECT(STRICT) AS ( name STRING, location GEO_POINT ), text STRING INDEX USING FULLTEXT WITH (analyzer = 'english'), created TIMESTAMP, image_ref STRING, like_count LONG ) WITH (number_of_replicas = '0-2');

mfussenegger commented 6 years ago

user has become a keyword in CrateDB, so it has be quoted, the following should work:

 CREATE TABLE guestbook.posts (
        id STRING PRIMARY KEY,
        "user" OBJECT(STRICT) AS (
            name STRING,
            location GEO_POINT
        ),
        text STRING INDEX USING FULLTEXT WITH (analyzer = 'english'),
        created TIMESTAMP,
        image_ref STRING,
        like_count LONG
    ) WITH (number_of_replicas = '0-2');

Thanks for reporting, we'll update the example.

kwthoma commented 6 years ago

Thanks for the quick response. Was able to create the table using the quotes.

mfussenegger commented 6 years ago

We've also updated sql/schema.sql (https://github.com/crate/crate-sample-apps/pull/69)