-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-40667][SQL] Refactor File Data Source Options #38113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c25dd3b
475b1ca
8aa51a8
dbf3dcd
73b96e8
0f70c19
7da64d8
e7abf39
1a6fc1c
2c62453
a33f961
457af97
d370228
2e2cc7c
a0c5869
85d2d98
c9cc459
3356952
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.spark.sql.catalyst | ||
|
|
||
| /** | ||
| * Interface defines the following methods for a data source: | ||
| * - register a new option name | ||
| * - retrieve all registered option names | ||
| * - valid a given option name | ||
| * - get alternative option name if any | ||
| */ | ||
| trait DataSourceOptions { | ||
| // Option -> Alternative Option if any | ||
| private val validOptions = collection.mutable.Map[String, Option[String]]() | ||
|
|
||
| /** | ||
| * Register a new Option. | ||
| */ | ||
| protected def newOption(name: String): String = { | ||
| validOptions += (name -> None) | ||
| name | ||
| } | ||
|
|
||
| /** | ||
| * Register a new Option with an alternative name. | ||
| * @param name Option name | ||
| * @param alternative Alternative option name | ||
| */ | ||
| protected def newOption(name: String, alternative: String): Unit = { | ||
| // Register both of the options | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how can we know which one is the primary one? for example, ENCODING is the primary one as it will be respected if both are set.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we don't really care about which one is primary here, the reason we want to track alternative options is that callers may want to provide an error / log a warning if both of the alternative options are provided. Which one will be respected could be decided by the caller. |
||
| validOptions += (name -> Some(alternative)) | ||
| validOptions += (alternative -> Some(name)) | ||
| } | ||
|
|
||
| /** | ||
| * @return All data source options and their alternatives if any | ||
| */ | ||
| def getAllOptions: scala.collection.Set[String] = validOptions.keySet | ||
|
|
||
| /** | ||
| * @param name Option name to be validated | ||
| * @return if the given Option name is valid | ||
| */ | ||
| def isValidOption(name: String): Boolean = validOptions.contains(name) | ||
|
|
||
| /** | ||
| * @param name Option name | ||
| * @return Alternative option name if any | ||
| */ | ||
| def getAlternativeOption(name: String): Option[String] = validOptions.get(name).flatten | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.