Python:JDBC 与 JayDeBeApi 的 Apache Drill 连接错误

Python: JDBC Connection Error to Apache Drill Error with JayDeBeApi

我正在尝试使用 jaydebeapi 库从 python 连接到 Apache Drill。

我已经通过 drill-embedded 在嵌入式模式下打开了 drill,网络 ui 在端口 8047 中正确运行。然后,我尝试通过 JDBC 通过 python 脚本:

import jaydebeapi
import jpype
import os

DRILL_HOME = os.environ["DRILL_HOME"]

classpath = DRILL_HOME + "/jars/jdbc-driver/drill-jdbc-all-1.17.0.jar"
jpype.startJVM(jpype.getDefaultJVMPath(), "-Djava.class.path=%s" % classpath)
conn = jaydebeapi.connect(
    'org.apache.drill.jdbc.Driver',
    'jdbc:drill:drillbit=localhost:8047'
)

但是我得到这个错误

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Traceback (most recent call last):
  File "jaydebe_drill.py", line 10, in <module>
    'jdbc:drill:drillbit=localhost:8047'
  File "/Users/user/opt/anaconda3/lib/python3.7/site-packages/jaydebeapi/__init__.py", line 412, 
in connect
    jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)
  File "/Users/user/opt/anaconda3/lib/python3.7/site-packages/jaydebeapi/__init__.py", line 230,
 in _jdbc_connect_jpype
    return jpype.java.sql.DriverManager.getConnection(url, *dargs)
jpype._jexception.SQLNonTransientConnectionExceptionPyRaisable: 
java.sql.SQLNonTransientConnectionException: 
Failure in connecting to Drill: oadd.org.apache.drill.exec.rpc.ChannelClosedException: 
Channel closed /127.0.0.1:62244 <--> localhost/127.0.0.1:8047.

有谁知道如何解决这个问题?

感谢@Luke Woodward 的建议,问题出在端口上。对于 drill-embedded,没有到 select 的端口。下面是一个完整的查询示例

import jaydebeapi
import jpype
import os
import pandas as pd

DRILL_HOME = os.environ["DRILL_HOME"]
classpath = DRILL_HOME + "/jars/jdbc-driver/drill-jdbc-all-1.17.0.jar"

jpype.startJVM(jpype.getDefaultJVMPath(), "-Djava.class.path=%s" % classpath)

conn = jaydebeapi.connect(
    'org.apache.drill.jdbc.Driver',
    'jdbc:drill:drillbit=localhost'
)

cursor = conn.cursor()

query = """
    SELECT *
    FROM dfs.`/Users/user/data.parquet`
    LIMIT 1
"""

cursor.execute(query)
columns = [c[0] for c in cursor.description]
data = cursor.fetchall()
df = pd.DataFrame(data, columns=columns)

df.head()