Cannot access the Hive tables through JDBC-in R - r

I am trying to fetch records of a hive table into R console.
I have successfully created the connection. However, when I try to access the hive table weblogs, it indicates that the table can't be found.
I have already created the weblogs table in HIVE and I have granted the permission on this table to the user from which I'm logged in.
I am using derbydb metaphore
weblogs <- dbReadTable(conn,"weblogs")
Error in .verify.JDBC.result(r, "Unable to retrieve JDBC result set
for ", : Unable to retrieve JDBC result set for SELECT * FROM
weblogs (Error while compiling statement: FAILED: SemanticException
[Error 10001]: Line 1:14 Table not found 'weblogs')

Related

Access parquet files in Azure DataBricks by R via RODBC

I successfully configured connection to Azure DataBricks cluster and can query tables with
conn <- odbcConnect("AzureDatabricks")
sqlQuery(conn, "SELECT * FROM my_table")
but I need to access parquet files.
In Databricks I can do it with this code:
%sql
Select * FROM parquet.`/path/to/folder`
If I try this by R as
sqlQuery(conn, "Select * FROM parquet.`/path/to/folder`")
I receive error:
[Simba][SQLEngine] Table or view not found: SPARK.parquet./path/to/folder"
[RODBC] ERROR: Could not SQLExecDirect 'Select * FROM parquet.`/path/to/folder`
Is there way to access parquet files via RODBC?
You are experiencing this issue due to an error in your sql query itself. When you run Select * FROM parquet./path/to/folder, command you will not see table or view not found due to syntax error.
Example: Sample example for understanding the issue (when you run SELECT * FROM parquer.'somepath'), you will see the syntax error.
Note: After creating a Dataframe from parquet file, you have to register it as a temp table to run sql queries on it.
val sqlContext = new org.apache.spark.sql.SQLContext(sc)
val df = sqlContext.read.parquet("src/main/resources/peopleTwo.parquet")
df.printSchema
// after registering as a table you will be able to run sql queries
df.registerTempTable("people")
sqlContext.sql("select * from people").collect.foreach(println)
Reference: Spark SQL guide - Parquet files
You need to add UseNativeQuery=1; parameter to the odbc connection string.
Examlpe: Driver={Simba Spark ODBC Driver};Host=[serverHost];Port=443;HTTPPath=[httpPath];ThriftTransport=2;SSL=1;AuthMech=3;UID=token;PWD=[pwd];UseNativeQuery=1;
https://docs.databricks.com/integrations/jdbc-odbc-bi.html#ansi-sql-92-query-support-in-odbc

MarkLogic ODBC for Tableau - Date casting error

I have a MarkLogic ODBC server for a tableau connection. I have created the view and is already accessible. However, I am having problems manipulating Date elements in Tableau. I've encountered the following error:
An error occurred while communicating with the Other Databases (ODBC) data source 'database (new.database) (__MarkLogic)'.
Bad Connection: Tableau could not connect to the data source.
ERROR: XDMP-CAST: (err:FORG0001) Invalid cast: () cast as xs:date;
Error while executing the query
SELECT SUM("database"."amount") AS "sum_amount_ok",
SUM("database"."offered") AS "sum_offered_ok",
"database"."type" AS "type"
FROM "new"."database" "database"
WHERE (CAST({fn TRUNCATE(EXTRACT(YEAR FROM CAST("database"."date_of_permit" AS DATE)),0)} AS INTEGER) = 2014)
GROUP BY 3
Running this query (removing the {fn} tag) in qconsole results in the same casting error. How do I resolve this?
Thanks!
Update:
As grtjn commented, there is a null entry in my data that is causing this casting error.

more info for R DBI::dbSendQuery?

Here is a line of code that used to work:
res <- DBI::dbSendQuery(con, "SELECT 1")
Now it says:
Error in .verify.JDBC.result(r, "Unable to retrieve JDBC result set for ", :
Unable to retrieve JDBC result set for SELECT 1 (Error executing query)
I'm connecting to a Presto instance. Likely there's a connection problem or some other non-SQL problem.
How do I get more logging or debug information from this interface? I'm using DBI 0.7, R 3.4.3 on OS X (darwin15.6.0).
I read some of the docs, and I don't see an interface to turn on logging, or debug info. Maybe a connection parameter?

Run Hive Query in R with Config

I'm able to successfully connect and run queries in R from Hive using library(DBI) and library(RJDBC)
However, I'm trying to set the following config
Set hive.execution.engine=mr;
When I try to use the following command (which is how I would query), I get an error:
dbGetQuery(conn_expp_team, "Set hive.execution.engine=mr")
Here is the error:
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!)
Use RJDBC::dbSendUpdate(conn, statement). Source: https://github.com/s-u/RJDBC/issues/25

Excel data not visible in analytics obiee

I have created a system DSN with oracle BI server driver adding a excel as source data. I was able to create a RPD. Once I logged in to analytic I was able to see the RPD in analysis. But if I select any column and check for the result I get an error like mentioned below. Please help me sort out this issue.
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 16001] ODBC error state: IM002 code: 0 message: [DataDirect][ODBC lib] Data source name not found and no default driver specified. (HY000)
SQL Issued: SELECT 0 s_0, "New"."Sample"."Customer Name" s_1 FROM "New" FETCH FIRST 65001 ROWS ONLY

Resources