我想从激活Oracle版本功能时可见的视图中进行选择。
alter session set EDITION=MYEDITION
view1
view1_edition1 => this view is only visible after the alter session statement above which is Oracle edition feature.
在TOAD中,一切正常。我在上面触发了alter session语句,并且可以从该视图中成功选择。
我正在尝试在Spark中实现此目标,但是它不起作用。从view1_edition1返回对象中选择是不存在的。
df = spark.read \
.format("jdbc") \
.option("url", "jdbc:oracle:thin:@db_server:1520/SERVICE") \
.option("driver", "oracle.jdbc.driver.OracleDriver") \
.option("dbtable", "(select name from schema1.view1_edition1)") \
.option("user", "user") \
.option("password", "password") \
.option("sessionInitStatement","""alter session set EDITION=MYEDITION""") \
.load()
仅是为了证明该版本处于活动状态,我在spark.read中触发了以下选择,并返回了正确的版本为活动状态
(
WITH a AS (SELECT name FROM SCHEMA1.TABLE1)
,b AS (SELECT SYS_CONTEXT('USERENV', 'SESSION_EDITION_NAME') AS
edition FROM DUAL)
SELECT name,edition
FROM a
CROSS JOIN b
)
答案 0 :(得分:1)
从Oracle JDBC数据源获取连接之前,请尝试使用Java属性设置版本名称,而不是alter session
例如 p.put(“ oracle.jdbc.editionName”,“ MyEdition”); ... ods.setConnectionProperties(p);