cfmcgrady commented on a change in pull request #1140:
URL: https://github.com/apache/incubator-kyuubi/pull/1140#discussion_r714576625
##########
File path:
dev/kyuubi-extension-spark-3-1/src/main/scala/org/apache/kyuubi/sql/sqlclassification/KyuubiGetSqlClassification.scala
##########
@@ -35,28 +35,25 @@ import org.apache.kyuubi.sql.KyuubiSQLConf._
* If there have no this named jsonFile,
* the service will upload the default matching rule:
sql-classification-default.json.
*/
-object KyuubiGetSqlClassification {
-
+object KyuubiGetSqlClassification extends Logging {
private val jsonNode: Option[JsonNode] = {
SQLConf.get.getConf(SQL_CLASSIFICATION_ENABLED) match {
case true =>
val objectMapper = new ObjectMapper
- var url: URL = Thread.currentThread().getContextClassLoader
- .getResource("sql-classification.json")
+ var url: URL =
getClass.getClassLoader.getResource("sql-classification.json")
if (url == null) {
- url = Thread.currentThread().getContextClassLoader
- .getResource("sql-classification-default.json")
+ logInfo("sql-classification.json is not found, use default config
instead")
+ url =
getClass.getClassLoader.getResource("sql-classification-default.json")
}
- val defaultSqlClassificationFile = url.getPath
- Some(objectMapper.readTree(new File(defaultSqlClassificationFile)))
+ Some(objectMapper.readTree(url))
case false =>
None
}
}
/**
* Notice:
- * You need to make sure that the configuration item:
kyuubi.spark.sql.classification.enabled
+ * You need to make sure that the configuration item:
SQL_CLASSIFICATION_ENABLED
* is true
Review comment:
nit: indent
##########
File path:
dev/kyuubi-extension-spark-3-1/src/main/scala/org/apache/kyuubi/sql/sqlclassification/KyuubiGetSqlClassification.scala
##########
@@ -35,28 +35,25 @@ import org.apache.kyuubi.sql.KyuubiSQLConf._
* If there have no this named jsonFile,
* the service will upload the default matching rule:
sql-classification-default.json.
*/
-object KyuubiGetSqlClassification {
-
+object KyuubiGetSqlClassification extends Logging {
private val jsonNode: Option[JsonNode] = {
SQLConf.get.getConf(SQL_CLASSIFICATION_ENABLED) match {
case true =>
val objectMapper = new ObjectMapper
- var url: URL = Thread.currentThread().getContextClassLoader
- .getResource("sql-classification.json")
+ var url: URL =
getClass.getClassLoader.getResource("sql-classification.json")
if (url == null) {
- url = Thread.currentThread().getContextClassLoader
- .getResource("sql-classification-default.json")
+ logInfo("sql-classification.json is not found, use default config
instead")
+ url =
getClass.getClassLoader.getResource("sql-classification-default.json")
}
- val defaultSqlClassificationFile = url.getPath
- Some(objectMapper.readTree(new File(defaultSqlClassificationFile)))
+ Some(objectMapper.readTree(url))
Review comment:
1. Shall we use `Option` instead?
2. Shall we also handle a malformed JSON case? `objectMapper.readTree()` may
throws `IOException/JsonProcessingException`.
--
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]