athena)

jjjwad0x  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(470)

我正在使用名为pyathenajdbc的python模块,以便使用提供的jdbc驱动程序查询athena。以下是链接:https://pypi.python.org/pypi/pyathenajdbc/
连接成功建立,查询也正常工作(显示数据库、显示表、选择…)但是,每当我尝试使用配置单元参数(如“row format serde..”)定义自定义表时,它就不再工作了,下面是我的代码:

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/';
                              """)

错误:第1:8行:输入“create external”(服务:amazonathena;状态码:400;错误代码:invalidrequestexception;请求id:0cca6f3e-fe9e-11e6-be4f-a3b28f284a77)
ps:同样的查询在控制台管理中也可以正常工作!有什么帮助吗?

voase2hg

voase2hg1#

您的查询格式不正确。
这是因为这条线:

'collection.delimm = 'undefined',

它缺少一个结束后报价 delimm .

相关问题