You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/07/01 04:41:32 UTC

[GitHub] [spark] HeartSaVioR opened a new pull request, #37041: [SPARK-39650][SS] Fix incorrect value schema in streaming deduplication with backward compatibility

HeartSaVioR opened a new pull request, #37041:
URL: https://github.com/apache/spark/pull/37041

   ### What changes were proposed in this pull request?
   
   This PR proposes to fix the incorrect value schema in streaming deduplication. It stores the empty row having a single column with null (using NullType), but the value schema is specified as all columns, which leads incorrect behavior from state store schema compatibility checker.
   
   This PR proposes to set the schema of value as `StructType(Array(StructField("__dummy__", NullType)))` to fit with the empty row. With this change, the streaming queries creating the checkpoint after this fix would work smoothly.
   
   To not break the existing streaming queries having incorrect value schema, this PR proposes to disable the check for value schema on streaming deduplication. Disabling the value check was there for the format validation (we have two different checkers for state store), but it has been missing for state store schema compatibility check. To avoid adding more config, this PR leverages the existing config "format validation" is using.
   
   ### Why are the changes needed?
   
   This is a bug fix. Suppose the streaming query below:
   
   ```
   # df has the columns `a`, `b`, `c`
   val df = spark.readStream.format("...").load()
   val query = df.dropDuplicate("a").writeStream.format("...").start()
   ```
   
   while the query is running, df can produce a different set of columns (e.g. `a`, `b`, `c`, `d`) from the same source due to schema evolution. Since we only deduplicate the rows with column `a`, the change of schema should not matter for streaming deduplication, but state store schema checker throws error saying "value schema is not compatible" before this fix.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No, this is basically a bug fix which end users wouldn't notice unless they encountered a bug.
   
   ### How was this patch tested?
   
   New tests.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HeartSaVioR closed pull request #37041: [SPARK-39650][SS] Fix incorrect value schema in streaming deduplication with backward compatibility

Posted by GitBox <gi...@apache.org>.
HeartSaVioR closed pull request #37041: [SPARK-39650][SS] Fix incorrect value schema in streaming deduplication with backward compatibility
URL: https://github.com/apache/spark/pull/37041


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HeartSaVioR commented on pull request #37041: [SPARK-39650][SS] Fix incorrect value schema in streaming deduplication with backward compatibility

Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on PR #37041:
URL: https://github.com/apache/spark/pull/37041#issuecomment-1172900851

   Thanks! Merging to master.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] viirya commented on a diff in pull request #37041: [SPARK-39650][SS] Fix incorrect value schema in streaming deduplication with backward compatibility

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #37041:
URL: https://github.com/apache/spark/pull/37041#discussion_r911614087


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/StateStore.scala:
##########
@@ -515,7 +515,12 @@ object StateStore extends Logging {
           val checker = new StateSchemaCompatibilityChecker(storeProviderId, hadoopConf)
           // regardless of configuration, we check compatibility to at least write schema file
           // if necessary
-          val ret = Try(checker.check(keySchema, valueSchema)).toEither.fold(Some(_), _ => None)
+          // if the format validation for value schema is disabled, we also disable the schema

Review Comment:
   Should we also add a code comment at `formatValidationCheckValue` in `StateStoreConf`?



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HeartSaVioR commented on pull request #37041: [SPARK-39650][SS] Fix incorrect value schema in streaming deduplication with backward compatibility

Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on PR #37041:
URL: https://github.com/apache/spark/pull/37041#issuecomment-1171979099

   I'll keep this PR around a day to seek for further reviews. If there is no outstanding one, I'll merge this in tomorrow.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HeartSaVioR commented on pull request #37041: [SPARK-39650][SS] Fix incorrect value schema in streaming deduplication with backward compatibility

Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on PR #37041:
URL: https://github.com/apache/spark/pull/37041#issuecomment-1171948944

   It's not important with current features of Structured Streaming. It's something like "future-proof" - when we plan to build a feature like reading the state (actually I even had a PR), keeping the schema up-to-date will give the ideal UX to the end users, otherwise they would see the outdated schema, or even fail to read the state.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HeartSaVioR commented on pull request #37041: [SPARK-39650][SS] Fix incorrect value schema in streaming deduplication with backward compatibility

Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on PR #37041:
URL: https://github.com/apache/spark/pull/37041#issuecomment-1171951079

   missed to cc. @xuanyuanking as he authored the other checker.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] viirya commented on pull request #37041: [SPARK-39650][SS] Fix incorrect value schema in streaming deduplication with backward compatibility

Posted by GitBox <gi...@apache.org>.
viirya commented on PR #37041:
URL: https://github.com/apache/spark/pull/37041#issuecomment-1171941045

   > This PR does not deal with overwriting incorrect value schema file. If we want to leverage the schema file for understanding/reading state, ideally we should make the schema file be up to date. But we don't also overwrite the schema file when the schema is compatible.
   
   Is that important? The state value is already not matched with the value schema, isn't? Not sure if that the schema is up to date is important.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HeartSaVioR commented on a diff in pull request #37041: [SPARK-39650][SS] Fix incorrect value schema in streaming deduplication with backward compatibility

Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on code in PR #37041:
URL: https://github.com/apache/spark/pull/37041#discussion_r911624697


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/StateStore.scala:
##########
@@ -515,7 +515,12 @@ object StateStore extends Logging {
           val checker = new StateSchemaCompatibilityChecker(storeProviderId, hadoopConf)
           // regardless of configuration, we check compatibility to at least write schema file
           // if necessary
-          val ret = Try(checker.check(keySchema, valueSchema)).toEither.fold(Some(_), _ => None)
+          // if the format validation for value schema is disabled, we also disable the schema

Review Comment:
   OK I'll leave a comment that the config is in effect for both checkers.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HeartSaVioR commented on pull request #37041: [SPARK-39650][SS] Fix incorrect value schema in streaming deduplication with backward compatibility

Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on PR #37041:
URL: https://github.com/apache/spark/pull/37041#issuecomment-1171935839

   This PR does not deal with overwriting incorrect value schema file. If we want to leverage the schema file for understanding/reading state, ideally we should make the schema file be up to date. But we don't also overwrite the schema file when the schema is compatible.
   
   We can track the effort as separate JIRA.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HeartSaVioR commented on pull request #37041: [SPARK-39650][SS] Fix incorrect value schema in streaming deduplication with backward compatibility

Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on PR #37041:
URL: https://github.com/apache/spark/pull/37041#issuecomment-1171930922

   cc. @zsxwing @viirya 


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HeartSaVioR commented on a diff in pull request #37041: [SPARK-39650][SS] Fix incorrect value schema in streaming deduplication with backward compatibility

Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on code in PR #37041:
URL: https://github.com/apache/spark/pull/37041#discussion_r911645293


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/StateStore.scala:
##########
@@ -515,7 +515,12 @@ object StateStore extends Logging {
           val checker = new StateSchemaCompatibilityChecker(storeProviderId, hadoopConf)
           // regardless of configuration, we check compatibility to at least write schema file
           // if necessary
-          val ret = Try(checker.check(keySchema, valueSchema)).toEither.fold(Some(_), _ => None)
+          // if the format validation for value schema is disabled, we also disable the schema

Review Comment:
   [1a95700](https://github.com/apache/spark/pull/37041/commits/1a95700e6e11eb0d5e4c3ad2ad61492d4b42be4f)



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org