Uh oh!
There was an error while loading. Please reload this page.
[SPARK-27106][SQL] merge CaseInsensitiveStringMap and DataSourceOptions - #24025
[SPARK-27106][SQL] merge CaseInsensitiveStringMap and DataSourceOptions#24025cloud-fan wants to merge 8 commits into
Conversation
| * Returns the boolean value to which the specified key is mapped, | ||
| * or defaultValue if there is no mapping for the key. The key match is case-insensitive | ||
| */ | ||
| public boolean getBoolean(String key, boolean defaultValue) { |
There was a problem hiding this comment.
These 4 methods are from DataSourceOptions, which are pretty general and useful.
| * A simple test suite to verify `DataSourceOptions`. | ||
| */ | ||
| class DataSourceOptionsSuite extends SparkFunSuite { | ||
| class CaseInsensitiveStringMapSuite extends SparkFunSuite { |
There was a problem hiding this comment.
It's awkward to write test in Java. I rewrite it in Scala and merge it with the original DataSourceOptionsSuite
cloud-fan
commented
Mar 8, 2019
I think this PR changes too many files... |
| sparkSession: SparkSession, | ||
| options: DataSourceOptions, | ||
| options: CaseInsensitiveStringMap, | ||
| paths: Seq[String], |
There was a problem hiding this comment.
Hi, @cloud-fan .
Should we change FileTable signature to accept paths additionally for merging DataSourceOptions and CaseInsensitiveStringMap?
There was a problem hiding this comment.
it's not a big deal. I did this because we need paths in the OrcDataSourceV2 as well, so we can calculate the paths only once in the OrcDataSourceV2.
Uh oh!
There was an error while loading. Please reload this page.
| } | ||
| val checkFilesExistsOption = DataSourceOptions.CHECK_FILES_EXIST_KEY -> "true" | ||
| // TODO: remove this option. | ||
| val checkFilesExistsOption = "check_files_exist" -> "true" |
There was a problem hiding this comment.
Could you file a JIRA and make this as an IDed TODO please?
Uh oh!
There was an error while loading. Please reload this page.
| eventually(timeout(streamingTimeout)) { | ||
| // Write options should not be set. | ||
| assert(LastWriteOptions.options.getBoolean(readOptionName, false) == false) | ||
| assert(LastReadOptions.options.getBoolean(readOptionName, false)) |
There was a problem hiding this comment.
Since this PR adds CaseInsensitiveStringMap.getBoolean, we don't need to change line 310.
| eventually(timeout(streamingTimeout)) { | ||
| // Read options should not be set. | ||
| assert(LastReadOptions.options.getBoolean(writeOptionName, false) == false) | ||
| assert(LastWriteOptions.options.getBoolean(writeOptionName, false)) |
SparkQA
commented
Mar 8, 2019
Test build #103216 has finished for PR 24025 at commit
|
cloud-fan
commented
Mar 9, 2019
One goal is to remove these pre-defined option keys, as the options should just be a general string-to-string map. I don't think it's a good idea to keep both |
SparkQA
commented
Mar 9, 2019
Test build #103254 has finished for PR 24025 at commit
|
dilipbiswal
commented
Mar 9, 2019
retest this please |
SparkQA
commented
Mar 9, 2019
Test build #103257 has finished for PR 24025 at commit
|
SparkQA
commented
Mar 9, 2019
Test build #4601 has started for PR 24025 at commit |
srowen
left a comment
There was a problem hiding this comment.
Generally looks good to me as a cleanup
dongjoon-hyun
commented
Mar 10, 2019
Retest this please. |
SparkQA
commented
Mar 10, 2019
Test build #103272 has finished for PR 24025 at commit
|
dongjoon-hyun
commented
Mar 10, 2019
Retest this please. |
| } match { | ||
| case Success(_) => | ||
| case Failure(_) => | ||
| throw new AnalysisException("includeTimestamp must be set to either \"true\" or \"false\"") |
There was a problem hiding this comment.
Hi, @cloud-fan .
It seems that we need to change this Try logic. For invalid values like fasle,
- Previously,
IllegalArgumentExceptionis thrown by ScalaStringLike.parseBoolean - Now, Java
Boolean.parseBooleanreturnsfalsewithout exceptions.
SparkQA
commented
Mar 11, 2019
Test build #103284 has finished for PR 24025 at commit
|
SparkQA
commented
Mar 11, 2019
Test build #103293 has finished for PR 24025 at commit
|
SparkQA
commented
Mar 12, 2019
Test build #103359 has finished for PR 24025 at commit
|
| /** | ||
| * Returns the integer value to which the specified key is mapped, | ||
| * or defaultValue if there is no mapping for the key. The key match is case-insensitive |
There was a problem hiding this comment.
Nit: add . at the end of line.
There was a problem hiding this comment.
it's too minor to trigger another QA round. I'll fix it in another PR if the current QA round passes.
gengliangwang
left a comment
There was a problem hiding this comment.
LGTM. I search all the java/scala/markdown files and there is no DataSourceOptions now.
SparkQA
commented
Mar 12, 2019
Test build #103366 has finished for PR 24025 at commit
|
dongjoon-hyun
commented
Mar 12, 2019
Oh, it's weird. So far, there is no successful Jenkins run in this PR. |
dongjoon-hyun
commented
Mar 12, 2019
Retest this please. |
SparkQA
commented
Mar 13, 2019
Test build #103376 has finished for PR 24025 at commit
|
gengliangwang
commented
Mar 13, 2019
retest this please |
dongjoon-hyun
commented
Mar 13, 2019
Hi, @cloud-fan . Could you check the test failure at |
SparkQA
commented
Mar 13, 2019
Test build #103408 has finished for PR 24025 at commit
|
SparkQA
commented
Mar 13, 2019
Test build #103404 has finished for PR 24025 at commit
|
dilipbiswal
commented
Mar 13, 2019
retest this please |
| override def toString: String = s"RateStreamV2[rowsPerSecond=$rowsPerSecond, " + | ||
| s"rampUpTimeSeconds=$rampUpTimeSeconds, " + | ||
| s"numPartitions=${options.get(NUM_PARTITIONS).orElse("default")}" | ||
| s"numPartitions=${Option(options.get(NUM_PARTITIONS)).getOrElse("default")}" |
There was a problem hiding this comment.
Nit: options.getOrDefault(NUM_PARTITIONS, "default")
There was a problem hiding this comment.
Too minor to update...Hopefully this time all tests are passed.
SparkQA
commented
Mar 13, 2019
Test build #103423 has finished for PR 24025 at commit
|
| Option(map.get("paths")).map { pathStr => | ||
| objectMapper.readValue(pathStr, classOf[Array[String]]).toSeq | ||
| }.orElse(Option(map.get("path")).map(Seq(_))).getOrElse { | ||
| throw new IllegalArgumentException("'path' must be given when reading files.") |
| objectMapper.readValue(pathStr, classOf[Array[String]]).toSeq | ||
| }.orElse(Option(map.get("path")).map(Seq(_))).getOrElse { | ||
| throw new IllegalArgumentException("'path' must be given when reading files.") | ||
| Nil |
There was a problem hiding this comment.
protected def getPaths(map: CaseInsensitiveStringMap): Seq[String] = {
Option(map.get("paths")).map { pathStr =>
val objectMapper = new ObjectMapper()
objectMapper.readValue(pathStr, classOf[Array[String]]).toSeq
}.getOrElse {
Option(map.get("path")).toSeq
}
}
SparkQA
commented
Mar 13, 2019
Test build #103433 has finished for PR 24025 at commit
|
SparkQA
commented
Mar 13, 2019
Test build #103435 has finished for PR 24025 at commit
|
cloud-fan
commented
Mar 13, 2019
thanks, merging to master! |
rdblue
commented
Mar 13, 2019
Thanks for working on this, @cloud-fan! |
It's a little awkward to have 2 different classes(`CaseInsensitiveStringMap` and `DataSourceOptions`) to present the options in data source and catalog API. This PR merges these 2 classes, while keeping the name `CaseInsensitiveStringMap`, which is more precise. existing tests Closesapache#24025 from cloud-fan/option. Authored-by: Wenchen Fan <wenchen@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
What changes were proposed in this pull request?
It's a little awkward to have 2 different classes(
CaseInsensitiveStringMapandDataSourceOptions) to present the options in data source and catalog API.This PR merges these 2 classes, while keeping the name
CaseInsensitiveStringMap, which is more precise.How was this patch tested?
existing tests