pan3793 commented on a change in pull request #1003:
URL: https://github.com/apache/incubator-kyuubi/pull/1003#discussion_r700016261



##########
File path: 
kyuubi-common/src/main/scala/org/apache/kyuubi/config/ConfigEntry.scala
##########
@@ -173,6 +173,29 @@ class ConfigEntryFallback[T](
   override def internal: Boolean = _internal
 }
 
+class OptionalConfigEntryFallback[T](
+                              _key: String,

Review comment:
       The indentation looks weird here.

##########
File path: 
kyuubi-common/src/test/scala/org/apache/kyuubi/config/ConfigEntrySuite.scala
##########
@@ -142,4 +142,30 @@ class ConfigEntrySuite extends KyuubiFunSuite {
     conf.set(origin.key, "new value")
     assert(conf.get(fallback) === "new value", "fallback to new original key")
   }
+
+  test("fallback optional config entry") {
+    val origin = KyuubiConf.buildConf("origin.spark")
+      .version("1.1.1")
+      .stringConf
+      .createOptional
+    val fallback =
+      new OptionalConfigEntryFallback[String](
+        "kyuubi.fallback.spark", null, null, "fallback", "1.2.0", false, 
origin)
+
+    assert(fallback.key === "kyuubi.fallback.spark")
+    assert(fallback.valueConverter("2") === Option("2"))
+    assert(fallback.strConverter(Option("2.0")) === "2.0")
+    assert(fallback.defaultValStr === ConfigEntry.UNDEFINED)
+    assert(fallback.doc === "fallback")
+    assert(fallback.version === "1.2.0")
+    assert(fallback.typ === "string")
+    assert(fallback.internal === false)
+    assert(fallback.toString === s"ConfigEntry(key=kyuubi.fallback.spark, " +
+      s"defaultValue=${ConfigEntry.UNDEFINED}, doc=fallback, version=1.2.0, 
type=string)")
+
+    val conf = KyuubiConf()
+    assert(conf.get(fallback) === None)
+    conf.set(origin.key, "new value")
+    assert(conf.get(fallback) === Option("new value"), "fallback to new 
original key")

Review comment:
       `Option("new value")` => `Some("new value")`




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