Apache Drill 1.2 and Oracle JDBC

2019-06-03 15:15发布

Using Apache Drill v1.2 and Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit in embedded mode.

I'm curious if anyone has had any success connecting Apache Drill to an Oracle DB. I've updated the drill-override.conf with the following configurations (per documents):

drill.exec: {
  cluster-id: "drillbits1",
  zk.connect: "localhost:2181",
  drill.exec.sys.store.provider.local.path = "/mypath"
}

and placed the ojdbc6.jar in \apache-drill-1.2.0\jars\3rdparty. I can successfully create the storage plug-in:

{
  "type": "jdbc",
  "driver": "oracle.jdbc.driver.OracleDriver",
  "url": "jdbc:oracle:thin:@<IP>:<PORT>:<SID>",
  "username": "USERNAME",
  "password": "PASSWORD",
  "enabled": true
}

but when I issue a query such as:

    select * from <storage_name>.<schema_name>.`dual`; 

I get the following error:

Query Failed: An Error Occurred
org.apache.drill.common.exceptions.UserRemoteException: VALIDATION ERROR: From line 1, column 15 to line 1, column 20: Table '<storage_name>.<schema_name>.dual' not found [Error Id: 57a4153c-6378-4026-b90c-9bb727e131ae on <computer_name>:<PORT>].

I've tried to query other schema/tables and get a similar result. I've also tried connecting to Teradata and get the same error. Does any one have suggestions/run into similar issues?

3条回答
该账号已被封号
2楼-- · 2019-06-03 15:37

It's working with Drill 1.3 (released on 23-Dec-2015)

Plugin: name - oracle

{
  "type": "jdbc",
  "driver": "oracle.jdbc.driver.OracleDriver",
  "url": "jdbc:oracle:thin:user/password@192.xxx.xxx.xxx:1521:orcl ",
  "enabled": true
}

Query:

select * from <plugin-name>.<user-name>.<table-name>;

Example:

select * from oracle.USER.SAMPLE;

Check drill's documentation for more details.

Note: Make sure you added ojdbc7.12.1.0.2.jar(recommended in docs) in apache-drill-1.3.0/jars/3rdparty

查看更多
在下西门庆
3楼-- · 2019-06-03 15:39

It kind of works in Apache drill 1.3. The strange thing is that I can only query the tables for which there are synonyms created... In the command line try:
use <storage_name>;
show tables;
This will give you a list of objects that you can query - dual is not on that list ;-).

查看更多
Deceive 欺骗
4楼-- · 2019-06-03 15:54

I'm using apache-drill-1.9.0 and it seems that the schema name is interpreted case sensitive and must be be therefore be in upper case.

For a table user1.my_tab (which is per default created in Oracle in upper case) this works in Drill (plugin name is oracle)

SELECT * FROM oracle.USER1.my_tab;

But this triggers an error

SELECT * FROM oracle.user1.my_tab;

SEVERE: org.apache.calcite.sql.validate.SqlValidatorException: Table 'oracle.user1.my_tab' not found

An alternative approach is to set the plugin name and the schema name with use (owner must be upper case as well)

0: jdbc:drill:zk=local> use oracle.USER1;
+-------+-------------------------------------------+
|  ok   |                  summary                  |
+-------+-------------------------------------------+
| true  | Default schema changed to [oracle.USER1]  |
+-------+-------------------------------------------+
1 row selected (0,169 seconds)
0: jdbc:drill:zk=local> select * from my_tab;
+------+
|  X   |
+------+
| 1.0  |
| 1.0  |
+------+
2 rows selected (0,151 seconds)
查看更多
登录 后发表回答