fix putHiveQL bug

This commit is contained in:
judy_0131 2019-07-29 13:52:19 +08:00
parent aab8b7854d
commit 0839e1c1a1
3 changed files with 11 additions and 16 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
### Scala template
*.class
*.log
*.iml
/.idea/
.DS_Store

View File

@ -25,19 +25,13 @@ class PutHiveQL extends ConfigurableStop {
import scala.io.Source
sql(sqlText= "use "+database)
var lines:String=""
//Source.fromFile(hiveQL_path).getLines().foreach(x=>{
HdfsUtil.getLines(hiveQL_path).foreach(x => {
if(x.contains(";")){
lines=lines+" "+x.replace(";","")
println(lines)
sql(sqlText = lines)
lines=""
}else{
lines=lines+" "+x
}
//val useDBText = "use "+database + ";"
var sqlString:String=HdfsUtil.getLines(hiveQL_path)
sqlString.split(";").foreach( s => {
println("Sql is " + s)
sql(s)
})
}
def initialize(ctx: ProcessContext): Unit = {
@ -45,7 +39,7 @@ class PutHiveQL extends ConfigurableStop {
}
def setProperties(map : Map[String, Any]): Unit = {
hiveQL_path = MapUtil.get(map,"hiveQL_path").asInstanceOf[String]
hiveQL_path = MapUtil.get(map,"hiveQL_Path").asInstanceOf[String]
database = MapUtil.get(map,"database").asInstanceOf[String]
}

View File

@ -54,9 +54,9 @@ object HdfsUtil {
line
}
def getLines(file : String) : List[String] = {
def getLines(file : String) : String = {
var result = List[String]()
var result = ""
var line : String = ""
var inputStream : FSDataInputStream = null
var bufferedReader : BufferedReader = null
@ -66,7 +66,7 @@ object HdfsUtil {
bufferedReader = new BufferedReader(new InputStreamReader(inputStream))
line = bufferedReader.readLine();
while (line != null){
result = line +: result
result = result + " " + line
line = bufferedReader.readLine()
}