val db_query="(select
a.id,
conn_owner,
applicationname,
IsDuplicateConnection
from ingestion.connections_metadata
a inner join ingestion.connectionlnk_data b on
a.id=b.connection_id inner join ingestion.application c on
b.application_id = c.id where a.id =23)db_query"
//为此创建df
val dbname= spark.read.format("jdbc")
.option("driver",com.microsoft.sqlserver.jdbc.SQLServerDriver)
.option("url",jdbc:sqlserver://sjmnb008hv.in.com:1433/ompm)
.option("user",MysqlUser)
.option("password", Password)
.option("dbtable", db_query)
.load()
//然后在此数据框上应用collect
dbname.collect.foreach{ x=>
var owner_name=x.get(1)
if(x.get(3).toString()=='Y'){
hive_db = hive_db.tolowerCase() + "_"
+ x.get(2).tostring().toLowerCase()
.replace(" ","").replace("-","_")
}
}
所以这里的x.get(3)将取空值,默认值是n。
暂无答案!
目前还没有任何答案,快来回答吧!