dbeaver / dbeaver

Free universal database tool and SQL client
https://dbeaver.io
Apache License 2.0
38.37k stars 3.32k forks source link

AWS Athena JDBC - Create Table #12225

Open philmassie opened 3 years ago

philmassie commented 3 years ago

I'm not sure this is a bug or a feature request, just a question. Apologies if this is the wrong way to ask for help or if I missed a related discussion. Also I'm a DBeaver and Athena newb...

Is your feature request related to a problem? Please describe. I am facing issues creating a table using the Athena drivers (https://s3.amazonaws.com/athena-downloads/drivers/JDBC/SimbaAthenaJDBC-2.0.16.1000/AthenaJDBC42.jar). Good chance it's user error but I cant find any guides. My connection works for selects etc.

Process I'm trying in DBeaver:

Reason: SQL Error [100071] [HY000]: [Simba]AthenaJDBC An error has been thrown from the AWS Athena client. line 1:14: no viable alternative at input 'CREATE TABLE "default"' [Execution ID not available]

SQL Error [100071] [HY000]: [Simba]AthenaJDBC An error has been thrown from the AWS Athena client. line 1:14: no viable alternative at input 'CREATE TABLE "default"' [Execution ID not available] [Simba]AthenaJDBC An error has been thrown from the AWS Athena client. line 1:14: no viable alternative at input 'CREATE TABLE "default"' [Execution ID not available] [Simba]AthenaJDBC An error has been thrown from the AWS Athena client. line 1:14: no viable alternative at input 'CREATE TABLE "default"' [Execution ID not available] line 1:14: no viable alternative at input 'CREATE TABLE "default"' (Service: AmazonAthena; Status Code: 400; Error Code: InvalidRequestException; Request ID: blah; Proxy: null) line 1:14: no viable alternative at input 'CREATE TABLE "default"' (Service: AmazonAthena; Status Code: 400; Error Code: InvalidRequestException; Request ID: blah; Proxy: null)


**Describe the solution you'd like**
It would be great to be able to get this done via DBeaver.

**Describe alternatives you've considered**
Using the AWS console, first you need to stage your data file(s), then there's a wizard type thing. Specifying field types are awkward though. There are other ways to manage this using crawlers too.

**Additional context**
The source data for he new table needs to be in S3, and I think this might be the step that DBeaver is not doing (possibly my fault). I'm fairly certain that my user has write access to the S3 location defined in the Connection settings > S3 Location but I think that location is for staging the query results, not sourcing new tables. Perhaps there is another property I can set to define an upload bucket/prefix?

From the documentation and fiddling in the UI, after the data has been staged the create table SQL would need to resemble:

CREATE EXTERNAL TABLE IF NOT EXISTS integer_table ( KeyColumn STRING, Column1 INT) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' WITH SERDEPROPERTIES ( 'serialization.format' = ',', 'field.delim' = ',' )LOCATION 's3://athena-examples/integer_table/'



Can DBeaver handle this scenario?
Thanks very much
kseniiaguzeeva commented 3 years ago

It is not implemented for now. So, it is more a feature request than a bug. We are going to add this functionality.