使用R从HANA提取表 [英] Extracting Table from HANA using R

查看:116
本文介绍了使用R从HANA提取表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我要抓的桌子.但是从我的HANA数据库中,我一直收到以下错误.我知道该表存在,因为我已经从Qlikview中提取了该表.

This is the table I am trying to grab. From my HANA Database however I keep getting the below error. I know the table exists as I have pulled it in from Qlikview.

在Qlikview中,我使用以下语法提取表格

From Qlikview I pull in the table using the below syntax

"_MY_SCHEMA_"."My.Table.Name/Table_ONE"

当我尝试使用R在R中做同样的事情时,我会使用以下内容来抓取同一张表

When I try to do the same thing in R using I use the following to grab the same table

mydate <- sqlFetch(myconn, "_MY_SCHEMA.My.Table.Name/Table_ONE")

这是我得到的错误

Error in odbcTableExists(channel, sqtable)
: table not found on channel

推荐答案

此问题是由将STRINGS封装在引号中引起的.在这种情况下,这发生在两个级别:

This problem is caused by the way STRINGS are encapsulated in quotes. In this scenario this happens in two levels:

  1. R命令参数(sqlFetch(连接对象参数,sql字符串参数)
  2. HANA SQL,其中表名称的文字字符串是必需的

您在两个步骤中都使用了双引号封装.在这两个步骤的每一个步骤中,都会从您使用的参数中提取字符串,其中包括删除最外面的封装标记(此处是双引号). 因此,在第1步之后,双引号消失了,HANA收到了没有双引号的字符串.
只要您实际上没有要求标识符的双引号就可以,但是在您的示例中,您实际上是这样做的. (区分大小写的标识符(带有特殊字符,例如/或.)必须使用双引号引起来).

You used the double-quotes encapsulation for both steps. In each of those two steps the strings get extracted from the parameter you used, which includes the removal of the outermost encapsulation markers which are the double-quotes here. So, after step 1 the double quotes are gone and HANA receives a string without them.
This is OK, as long as you don't actually require the double-quotes for your identifiers, but in your example you actually do. (case sensitive identifiers with special characters like / or . require the double quotes).

解决方案非常简单:R允许单引号(')和双引号()都用于字符串封装.
只需在R中使用单引号将字符串移交即可:

The solution to this is rather simple: R allows both single (') and double (") quotes to be used for string encapsulation.
Just use single quotation marks in R to hand over the string:

mydate <- sqlFetch(myconn, '_MY_SCHEMA."My.Table.Name/Table_ONE"')

注意:您仍然必须将"My.Table.Name/Table_ONE"用双引号引起来,以便HANA能够正确处理此标识符.

Notice: you still have to encapsulate "My.Table.Name/Table_ONE" in double quotation marks so that HANA will handle this identifier correctly.

关于R与HANA的联系,还有两个博客:

For the connection R to HANA there are also a couple of blogs out:

  • HANA quick note checking my connections ...
  • HANA meets R

这篇关于使用R从HANA提取表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆