user3788005
user3788005

Reputation: 27

Crate DB exception, no viable alternative at input 'VARCHAR'

I'm using Elastic search to store large amount of data to make it searchable, but for configuration items I'm still using HSQL DB.

Is it possible to eliminate HSQL DB completely and use my existing Elastic search in combination with Crate DB?

Things I have tried:

  1. tried connecting to my existing Elastic search using Crate driver and Crate client but I got an exception No handler found for action "crate_sql". Does that mean I cannot use my existing ES and have to use inbuilt ES in crateDB??

  2. After connecting to crateDB elastic search (and not my existing ES). I was able to get connection using CrateDriver and run SQL queries. But in one of module I'm creating table using below command:

    create table some_table_name ( id VARCHAR(256), userName VARCHAR(256), fieldName VARCHAR(256),

    primary key (id), unique (userName, fieldName) );

...but then I got an exception:

io.crate.action.sql.SQLActionException: line 1:28: no viable alternative at input 'VARCHAR'

Does that mean I cannot write create table query using SQL syntax and SQL data types?

I know it will work if I use string data type instead of varchar, but I don't want to change all those queries now.

Upvotes: 0

Views: 1565

Answers (1)

mfussenegger
mfussenegger

Reputation: 3971

1)

No you cannot use existing ES nodes together with Crate. The whole SQL analyzer/planner/execution layer is done server side, not client side. In fact the crate clients are rather dumb.

2)

You'll have to change the types and also remove / change anything that isn't supported by crate. For example defaults or unique constraints aren't supported (up to 0.39 - in the future support might be added)

In your case the varchar type isn't valid in Crate, instead you'll have to use "string".

See Data Types Documentation for a list of supported data types.

Upvotes: 3

Related Questions