要在Python中查询Hive结果集,您可以使用pyhive库或pandas库。
使用pyhive库:
pip install pyhive
from pyhive import hive
conn = hive.Connection(host="your_hive_host", port=10000, username="your_username", database="your_database")
cursor = conn.cursor()
cursor.execute("SELECT * FROM your_table")
results = cursor.fetchall()
使用pandas库:
pip install pandas
import pandas as pd
from pyhive import hive
conn = hive.Connection(host="your_hive_host", port=10000, username="your_username", database="your_database")
df = pd.read_sql("SELECT * FROM your_table", conn)
请注意,您需要将"your_hive_host",“your_username”,"your_database"和"your_table"替换为实际的Hive连接和查询参数。