Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/16220#discussion_r91637540
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/streaming/StreamingQueryManager.scala
---
@@ -206,21 +219,21 @@ class StreamingQueryManager private[sql]
(sparkSession: SparkSession) {
recoverFromCheckpointLocation: Boolean = true,
trigger: Trigger = ProcessingTime(0),
triggerClock: Clock = new SystemClock()): StreamingQuery = {
- activeQueriesLock.synchronized {
- val name = userSpecifiedName match {
- case Some(n) =>
- if (activeQueries.values.exists(_.name ==
userSpecifiedName.get)) {
- throw new IllegalArgumentException(
- s"Cannot start query with name $n as a query with that name
is already active")
- }
- n
- case None => null
+ userSpecifiedName foreach { name =>
+ activeQueriesLock.synchronized {
+ if (activeQueries.values.exists(_.name == name) ||
pendingQueryNames.contains(name)) {
+ throw new IllegalArgumentException(
+ s"Cannot start query with name $name as a query with that name
is already active")
+ }
+ pendingQueryNames += name
}
+ }
+ try {
val checkpointLocation = userSpecifiedCheckpointLocation.map {
userSpecified =>
new Path(userSpecified).toUri.toString
}.orElse {
df.sparkSession.sessionState.conf.checkpointLocation.map {
location =>
- new Path(location, name).toUri.toString
+ new Path(location,
userSpecifiedName.getOrElse(UUID.randomUUID().toString)).toUri.toString
--- End diff --
Can you add a unit test to verify this behavior. The test can something
like
- with userspecified location, see if it creates the right directory
- without userspecified location and without SQL conf, see if it creates a
unique CP directory
- without userspecified location and with SQL conf, see if it creates a
unique CP directory
This can be in the StreamingQueryManager and would be easier if creating
the query becomes a separate function.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]