xiaonanyang-db commented on code in PR #38113:
URL: https://github.com/apache/spark/pull/38113#discussion_r989547833


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/FileSourceOptions.scala:
##########
@@ -40,3 +40,42 @@ object FileSourceOptions {
   val IGNORE_CORRUPT_FILES = "ignoreCorruptFiles"
   val IGNORE_MISSING_FILES = "ignoreMissingFiles"
 }
+
+/**
+ * Interface defines for a file-based data source, how to
+ *  - register a new option name
+ *  - retrieve all registered option names
+ *  - valid a given option name
+ *  - get alternative option name if any
+ */
+trait FileSourceOptionsSet {
+  private val validOptions = collection.mutable.Map[String, Option[String]]()
+
+  /**
+   * Register a new Option. If two options are alternative to each other, each 
of them needs to be
+   * registered individually
+   * @param name The primary option name
+   * @param alternative Alternative option name if any
+   */
+  protected def newOption(name: String, alternative: Option[String] = None): 
String = {
+    validOptions += (name -> alternative)
+    name
+  }
+
+  /**
+   * @return All valid file source options
+   */
+  def getAllValidOptionNames: scala.collection.Set[String] = 
validOptions.keySet
+
+  /**
+   * @param name Option name to be validated
+   * @return if the given Option name is valid
+   */
+  def isValidOptionName(name: String): Boolean = validOptions.contains(name)

Review Comment:
   `alternative` name is also registered as a valid option in the key of the 
map.



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

Reply via email to