thomasg19930417 commented on code in PR #4354:
URL: https://github.com/apache/kyuubi/pull/4354#discussion_r1110536914
##########
externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/KyuubiSparkUtil.scala:
##########
@@ -52,7 +59,49 @@ object KyuubiSparkUtil extends Logging {
}
}
+ def getInitializeSql(sparkSession: SparkSession, config: Seq[String]):
Seq[String] = {
+
+ def getSqlTextFromFile(path: Option[String]): Seq[String] = {
+ path.map(filePath => {
+ var reader: BufferedReader = null
+ try {
+ info(s"========>load init sql from file: ${filePath}")
+ val engineInitSqlFilePath = new Path(filePath)
+ val hadoopConf = sparkSession.sparkContext.hadoopConfiguration
+ val fs: FileSystem = engineInitSqlFilePath.getFileSystem(hadoopConf)
+ if (fs.exists(engineInitSqlFilePath)) {
+ val sqlInputStream: FSDataInputStream =
fs.open(engineInitSqlFilePath)
+ reader = new BufferedReader(new InputStreamReader(sqlInputStream))
+ // Filter out the sql using '--' comment
+ val sqlText = ListBuffer[String]()
+ Stream.continually(reader.readLine())
+ .takeWhile(null != _).filter(item => !item.startsWith("--") &&
item.length > 0)
+ .map(item => item.replace(";", "")).foreach(item =>
sqlText.append(item))
Review Comment:
OK, I will modify it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]