作者:菜鸟一号 | 来源:互联网 | 2023-09-10 11:11
IhavebeentryingtowriteanRscripttoqueryImpaladatabase.Hereisthequerytothedatabase:
I have been trying to write an R script to query Impala database. Here is the query to the database:
我一直在尝试写一个R脚本以查询Impala数据库。下面是对数据库的查询:
select columnA, max(columnB) from databaseA.tableA where columnC in (select distinct(columnC) from databaseB.tableB ) group by columnA order by columnA
When I run this query manually (read: outside the Rscript via impala-shell), I am able to get the table contents. However, when the same is tried via the R script, I get the following error:
当我手动运行这个查询(通过impala-shell读取:Rscript之外)时,我能够获得表内容。但是,当通过R脚本进行同样的尝试时,我得到以下错误:
[1] "HY000 140 [Cloudera][ImpalaODBC] (140) Unsupported query."
[2] "[RODBC] ERROR: Could not SQLExecDirect 'select columnA, max(columnB) from databaseA.tableA where columnC in (select distinct(columnC) from databaseB.tableB ) group by columnA order by columnA'
closing unused RODBC handle 1
Why does the query fail when tried via R? and how do I fix this? Thanks in advance :)
为什么通过R尝试查询会失败?我该怎么解决这个问题呢?提前谢谢:)
Edit 1:
编辑1:
The connection script looks as below:
连接脚本如下所示:
library("RODBC");
connection <- odbcConnect("Impala");
query <- "select columnA, max(columnB) from databaseA.tableA where columnC in (select distinct(columnC) from databaseB.tableB ) group by columnA order by columnA";
data <- sqlQuery(connection,query);
1 个解决方案