I am using the python module called PyAthenaJDBC in order to query Athena using the provided JDBC driver. Here is the link : https://pypi.python.org/pypi/PyAthenaJDBC/
The connection is established successfully, the queries are working as well (Show databases, show tables, Select ... ) However, whenever I try to define a custom table using Hive arguments such as 'ROW FORMAT SERDE..' It's not working anymore, Here is my code :
class PyAthenaLoader():
def connecti(self):
self.conn = pyathenajdbc.connect(
access_key=access_key_id,
secret_key=secret_key_id,
region_name = "us-west-2",
s3_staging_dir="s3://aws-athena-query-results-332333536009-us-west-2")
def create(self):
try:
with self.conn.cursor() as cursor:
cursor.execute(
"""CREATE EXTERNAL TABLE IF NOT EXISTS sales4 (
Day_ID int,
Product_Id string,
Store_Id string,
Sales_Units int,
Sales_Cost float,
Currency string
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'serialization.format' = '|',
'field.delim' = '|',
'collection.delimm = 'undefined',
'mapkey.delim' = 'undefined'
) LOCATION 's3://athena/';
""")
Error : line 1:8: no viable alternative at input 'CREATE EXTERNAL' (Service: AmazonAthena; Status Code: 400; Error Code: InvalidRequestException; Request ID: 0cca6f3e-fe9e-11e6-be4f-a3b28f284a77)
PS: That same query works just fine in the console management! Any help?
Your query is malformed.
It is due to this line:
'collection.delimm = 'undefined',
It is missing a close-quote after delimm
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.