PyAthenaJDBC (AWS athena) 中的 HIVE 参数

HIVE Arguments in PyAthenaJDBC (AWS athena)

我正在使用名为 PyAthenaJDBC 的 python 模块,以便使用提供的 JDBC 驱动程序查询 Athena。 这是 link :https://pypi.python.org/pypi/PyAthenaJDBC/

连接已成功建立,查询也正常(显示数据库,显示 tables,Select ...) 但是,每当我尝试使用 'ROW FORMAT SERDE..' 等 Hive 参数定义自定义 table 时,它就不再起作用了, 这是我的代码:

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:同样的查询在控制台管理中工作得很好! 有帮助吗?

您的查询格式不正确。

这是由于这一行:

'collection.delimm = 'undefined',

delimm 之后缺少右引号。