在尝试使用将行插入分区的配置单元表时,我的写入速度非常慢 impyla
.
这是我用python编写的代码的一个示例:
from impala.dbapi import connect
targets = ... # targets is a dictionary of objects of a specific class
yesterday = datetime.date.today() - datetime.timedelta(days=1)
log_datetime = datetime.datetime.now()
query = """
INSERT INTO my_database.mytable
PARTITION (year={year}, month={month}, day={day})
VALUES ('{yesterday}', '{log_ts}', %s, %s, %s, 1, 1)
""".format(yesterday=yesterday, log_ts=log_datetime,
year=yesterday.year, month=yesterday.month,
day=yesterday.day)
print(query)
rows = tuple([tuple([i.campaign, i.adgroup, i.adwordsid])
for i in targets.values()])
connection = connect(host=os.environ["HADOOP_IP"],
port=10000,
user=os.environ["HADOOP_USER"],
password=os.environ["HADOOP_PASSWD"],
auth_mechanism="PLAIN")
cursor = connection.cursor()
cursor.execute("SET hive.exec.dynamic.partition.mode=nonstrict")
cursor.executemany(query, rows)
有趣的是,尽管我要发布 executemany
命令 impyla
仍然将其解析为多个mapreduce作业。事实上,我可以看到启动的mapreduce作业与传递给 impyla.executemany
方法。
你看到什么不对劲了吗?一个多小时后给你一个想法,它只写了350行。
暂无答案!
目前还没有任何答案,快来回答吧!