前提条件:hive中创建分区表,并指定分区键
create table test(
id stirng
)partitioned by (name string)
stored as orc;
创建sparksession,不需要认证的话去掉config中内容
SparkSession ss = SparkSession.builder()
.appName("test ")
.master("local[2]"
.enableHiveSupport()
.config("spark.sql.authorization.enabled", true)
.config("hive.security.authorization.enabled", true)
.getOrCreate();
读取oracle中数据
String sql = "(select xxx.*, 'a' as name from xxx where time >= trunc(sysdate) ) a";
Dataset<Row> table = ss.read()
.format("jdbc")
.option("driver", "oracle.jdbc.OracleDriver")
.option("url", "jdbc:oracle:thin:@1.1.1.1:1521:orcl")
.option("user", &#