Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
address comments
  • Loading branch information
cloud-fan committed Apr 10, 2018
commit c5e403c960cdfb68755df754abf7aa96ac6d40bc
Original file line number Diff line number Diff line change
Expand Up @@ -163,21 +163,14 @@ public double getDouble(String key, double defaultValue) {
*/
public static final String DATABASE_KEY = "database";

/**
* Returns the value of the singular path option.
*/
public Optional<String> path() {
return get(PATH_KEY);
}

/**
* Returns all the paths specified by both the singular path option and the multiple
* paths option.
*/
public String[] paths() {
String[] singularPath = path().map(s -> new String[]{s}).orElseGet(() -> new String[0]);
String[] singularPath =
get(PATH_KEY).map(s -> new String[]{s}).orElseGet(() -> new String[0]);
Optional<String> pathsStr = get(PATHS_KEY);
System.out.println(pathsStr);
if (pathsStr.isPresent()) {
ObjectMapper objectMapper = new ObjectMapper();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class DataSourceOptionsSuite extends SparkFunSuite {
DataSourceOptions.PATH_KEY -> "abc",
DataSourceOptions.TABLE_KEY -> "tbl").asJava)

assert(options.path.get() == "abc")
assert(options.paths().toSeq == Seq("abc"))
assert(options.tableName().get() == "tbl")
assert(!options.databaseName().isPresent)
}
Expand All @@ -95,15 +95,13 @@ class DataSourceOptionsSuite extends SparkFunSuite {
DataSourceOptions.PATH_KEY -> "abc",
DataSourceOptions.PATHS_KEY -> """["c", "d"]""").asJava)

assert(options.path.get() == "abc")
assert(options.paths().toSeq == Seq("abc", "c", "d"))
}

test("standard options with only multi-paths") {
val options = new DataSourceOptions(Map(
DataSourceOptions.PATHS_KEY -> """["c", "d\"e"]""").asJava)

assert(!options.path.isPresent)
assert(options.paths().toSeq == Seq("c", "d\"e"))
}
}