有没有办法使元数据无效并从 CDSW 中的 python 代码重建索引?

Is there a way to invalidate metadata and rebuild index from python code in CDSW?

我在 CDSW 中使用 Impyla 和 Python 来查询 HDFS 中的数据并使用它。问题有时是获取我必须进入的所有数据并手动单击 HUE 中的 "Invalidate all metadata and rebuild index" 按钮。

有没有办法在 workbench 中使用库或 python 代码来做到这一点?

我假设您正在使用类似的东西通过 impyla 连接到 impala ...尝试执行 invalidate metadata <table_name> 命令

from impala.dbapi import connect
conn = connect(host='my.host.com', port=21050)
cursor = conn.cursor()
cursor.execute('INVALIDATE METADATA mytable') # run this
cursor.execute('SELECT * FROM mytable LIMIT 100')
print cursor.description  # prints the result set's schema
results = cursor.fetchall()