zhang1002 commented on a change in pull request #1037:
URL: https://github.com/apache/incubator-kyuubi/pull/1037#discussion_r703490533



##########
File path: 
dev/kyuubi-extension-spark-3-1/src/main/scala/org/apache/kyuubi/sql/sqlclassification/KyuubiGetSqlClassification.scala
##########
@@ -28,22 +28,29 @@ import org.apache.kyuubi.sql.KyuubiSQLConf._
  * This object is used for getting sql_classification by the logicalPlan's 
simpleName.
  * When the configuration item: SQL_CLASSIFICATION_ENABLED is on,
  * we will load the rule from sql-classification-default.json.
+ *
+ * Notice:
+ *  We support the user use the self-defined matching rule: 
sql-classification.json.
+ *  If there have no this named jsonFile,
+ *  the service will upload the default matching rule: 
sql-classification-default.json.
  */
 object KyuubiGetSqlClassification {
 
   private val jsonNode: Option[JsonNode] = {
     SQLConf.get.getConf(SQL_CLASSIFICATION_ENABLED) match {
       case true =>
+        val objectMapper = new ObjectMapper
+        var defaultSqlClassificationFile: String = null
         try {
-          val defaultSqlClassificationFile =
-            Thread.currentThread().getContextClassLoader
-              .getResource("sql-classification-default.json").getPath
-          val objectMapper = new ObjectMapper
-          Some(objectMapper.readTree(new File(defaultSqlClassificationFile)))
+          defaultSqlClassificationFile = 
Thread.currentThread().getContextClassLoader
+            .getResource("sql-classification.json").getPath
         } catch {
-          case e: Exception =>
-            throw new 
IllegalArgumentException("sql-classification-default.json is not exist.", e)
+          case e: NullPointerException =>

Review comment:
       the method: getResource is an nullAble method. so we can get null_object.
   
   why i use this exception:
   Because when the jsonFile is not exist, this line only throw 
NullPointerException, so i can only catch this exception...




-- 
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]


Reply via email to