我能够使用库(DBI)和库(RJDBC)从Hive成功连接和运行R中的查询
但是,我尝试设置以下配置
Set hive.execution.engine=mr;
当我尝试使用以下命令时(我将查询它),我收到一个错误:
dbGetQuery(conn_expp_team, "Set hive.execution.engine=mr")
这是错误:
Error in .verify.JDBC.result(r, "Unable to retrieve JDBC result set for ", :
Unable to retrieve JDBC result set for Set hive.execution.engine=mr (The query did not generate a result set!)
答案 0 :(得分:1)
使用import numpy as np
def calc_combination(N1, N2, n1, n2, theta, phi):
N1 = N1[(N1 >= 0) & (N1 <= n1)]
N2 = N2[(N2 >= 0) & (N2 <= n2)]
a = N2 * theta + phi
res = N1.reshape(N1.shape[0], 1) - a.reshape(1, a.shape[0])
indices = np.argwhere(res >= 0)
pairs = zip(N1[indices[:,0]], N2[indices[:,1]])
return pairs
def test_case():
n1 = 5
n2 = 1
theta = 2
phi = 2
N1 = np.arange(n1 + 1)
N2 = np.arange(n2 + 1)
assert (calc_combination(N1, N2, n1, n2, theta, phi) ==
[(2, 0), (3, 0), (4, 0), (4, 1), (5, 0), (5, 1)])
test_case()
。资料来源:https://github.com/s-u/RJDBC/issues/25