You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "panbingkun (via GitHub)" <gi...@apache.org> on 2023/09/16 03:11:30 UTC

[GitHub] [spark] panbingkun opened a new pull request, #42952: [SPARK-45184][SQL] Remove orphaned error class documents

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

   ### What changes were proposed in this pull request?
   The pr aims to remove orphaned error class documents, include:
   1.Introducing an automated mechanism for removing orphaned files.
   2.Remove two orphaned error class documents:  `sql-error-conditions-incompatible-data-to-table-error-class.md` and `sql-error-conditions-unsupported-temp-view-operation-error-class.md`
   
   ### Why are the changes needed?
   - Keep error documents clear.
   - There are two possibilities for generating orphaned error documents: 
   The first, when we are performing error class refactoring without deleting the error class document that has already been refactored; 
   The second, modify the error class name based on the suggestions submitted by the reviewer in code review, but unintentionally submit the previous error class document.
   
   ### Does this PR introduce _any_ user-facing change?
   No.
   
   ### How was this patch tested?
   - Manually test.
   - Pass GA.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   No.


-- 
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] Hisoka-X commented on a diff in pull request #42952: [SPARK-45184][SQL] Remove orphaned error class documents

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #42952:
URL: https://github.com/apache/spark/pull/42952#discussion_r1327921647


##########
core/src/test/scala/org/apache/spark/SparkThrowableSuite.scala:
##########
@@ -222,6 +223,21 @@ class SparkThrowableSuite extends SparkFunSuite {
          |---""".stripMargin
     }
 
+    def orphanedGoldenFiles(): Iterable[File] = {
+      val errors = errorReader.errorInfoMap

Review Comment:
   nit: in fact `errors` already be created in https://github.com/apache/spark/pull/42952/files#diff-b3bc05fec45cd951053b2876c71c7730b63789cb4336a7537a6654c724db3241R154



##########
core/src/test/scala/org/apache/spark/SparkThrowableSuite.scala:
##########
@@ -323,6 +339,23 @@ class SparkThrowableSuite extends SparkFunSuite {
       assert(sqlErrorParentDoc.trim == commonErrorsInDoc.trim,
         "The error class document is not up to date. Please regenerate it.")
     }
+
+    val orphans = orphanedGoldenFiles()
+    if (regenerateGoldenFiles) {
+      if (orphans.nonEmpty) {
+        logInfo(s"Orphaned error class documents (${orphans.size}) is not empty, " +
+          s"executing cleanup operation.")
+        orphans.foreach { f =>
+          FileUtils.deleteQuietly(f)
+          logInfo(s"Cleanup orphaned error document: ${f.getName}.")
+        }
+      } else {
+        logInfo(s"Orphaned error class documents is empty")
+      }
+    } else {
+      assert(orphans.isEmpty,
+        "Exist orphaned error class documents. Please regenerate it.")

Review Comment:
   Maybe we can add `orphans` value in error msg. Then developers can also just delete it by hands.



##########
core/src/test/scala/org/apache/spark/SparkThrowableSuite.scala:
##########
@@ -222,6 +223,21 @@ class SparkThrowableSuite extends SparkFunSuite {
          |---""".stripMargin
     }
 
+    def orphanedGoldenFiles(): Iterable[File] = {
+      val errors = errorReader.errorInfoMap
+      val subErrorFileNames = errors.filter(_._2.subClass.isDefined).map(error => {
+        getErrorPath(error._1) + ".md"
+      }).toSet
+
+      val docsDir = getWorkspaceFilePath("docs")
+      val orphans = FileUtils.listFiles(docsDir.toFile, Array("md"), false).filter { f =>
+        (f.getName.startsWith("sql-error-conditions-") && f.getName.endsWith("-error-class.md")) &&
+          !f.getName.equals("sql-error-conditions-sqlstates.md") &&

Review Comment:
   ```suggestion
   ```
   I believe if `(f.getName.startsWith("sql-error-conditions-") && f.getName.endsWith("-error-class.md"))` is true, this condition is also true.



##########
core/src/test/scala/org/apache/spark/SparkThrowableSuite.scala:
##########
@@ -323,6 +339,23 @@ class SparkThrowableSuite extends SparkFunSuite {
       assert(sqlErrorParentDoc.trim == commonErrorsInDoc.trim,
         "The error class document is not up to date. Please regenerate it.")
     }
+
+    val orphans = orphanedGoldenFiles()
+    if (regenerateGoldenFiles) {
+      if (orphans.nonEmpty) {
+        logInfo(s"Orphaned error class documents (${orphans.size}) is not empty, " +
+          s"executing cleanup operation.")
+        orphans.foreach { f =>
+          FileUtils.deleteQuietly(f)
+          logInfo(s"Cleanup orphaned error document: ${f.getName}.")
+        }
+      } else {
+        logInfo(s"Orphaned error class documents is empty")

Review Comment:
   ```suggestion
           logInfo("Orphaned error class documents is empty")
   ```



##########
core/src/test/scala/org/apache/spark/SparkThrowableSuite.scala:
##########
@@ -323,6 +339,23 @@ class SparkThrowableSuite extends SparkFunSuite {
       assert(sqlErrorParentDoc.trim == commonErrorsInDoc.trim,
         "The error class document is not up to date. Please regenerate it.")
     }
+
+    val orphans = orphanedGoldenFiles()
+    if (regenerateGoldenFiles) {
+      if (orphans.nonEmpty) {
+        logInfo(s"Orphaned error class documents (${orphans.size}) is not empty, " +
+          s"executing cleanup operation.")

Review Comment:
   ```suggestion
             "executing cleanup operation.")
   ```



-- 
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] panbingkun commented on pull request #42952: [SPARK-45184][SQL] Remove orphaned error class documents

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on PR #42952:
URL: https://github.com/apache/spark/pull/42952#issuecomment-1722118084

   cc @cloud-fan @MaxGekk 


-- 
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] panbingkun commented on a diff in pull request #42952: [SPARK-45184][SQL] Remove orphaned error class documents

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on code in PR #42952:
URL: https://github.com/apache/spark/pull/42952#discussion_r1327937136


##########
core/src/test/scala/org/apache/spark/SparkThrowableSuite.scala:
##########
@@ -222,6 +223,21 @@ class SparkThrowableSuite extends SparkFunSuite {
          |---""".stripMargin
     }
 
+    def orphanedGoldenFiles(): Iterable[File] = {
+      val errors = errorReader.errorInfoMap
+      val subErrorFileNames = errors.filter(_._2.subClass.isDefined).map(error => {
+        getErrorPath(error._1) + ".md"
+      }).toSet
+
+      val docsDir = getWorkspaceFilePath("docs")
+      val orphans = FileUtils.listFiles(docsDir.toFile, Array("md"), false).filter { f =>
+        (f.getName.startsWith("sql-error-conditions-") && f.getName.endsWith("-error-class.md")) &&
+          !f.getName.equals("sql-error-conditions-sqlstates.md") &&

Review Comment:
   Yeah, let me remove it.
   All done.



-- 
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] Hisoka-X commented on a diff in pull request #42952: [SPARK-45184][SQL] Remove orphaned error class documents

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #42952:
URL: https://github.com/apache/spark/pull/42952#discussion_r1327921121


##########
core/src/test/scala/org/apache/spark/SparkThrowableSuite.scala:
##########
@@ -323,6 +339,23 @@ class SparkThrowableSuite extends SparkFunSuite {
       assert(sqlErrorParentDoc.trim == commonErrorsInDoc.trim,
         "The error class document is not up to date. Please regenerate it.")
     }
+
+    val orphans = orphanedGoldenFiles()
+    if (regenerateGoldenFiles) {
+      if (orphans.nonEmpty) {
+        logInfo(s"Orphaned error class documents (${orphans.size}) is not empty, " +
+          s"executing cleanup operation.")
+        orphans.foreach { f =>
+          FileUtils.deleteQuietly(f)
+          logInfo(s"Cleanup orphaned error document: ${f.getName}.")
+        }
+      } else {
+        logInfo(s"Orphaned error class documents is empty")
+      }
+    } else {
+      assert(orphans.isEmpty,
+        "Exist orphaned error class documents. Please regenerate it.")

Review Comment:
   ~~Maybe we can add `orphans` value in error msg. Then developers can also just delete it by hands.~~
   
   Ignore it. It already would print list at now.



-- 
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] cloud-fan commented on pull request #42952: [SPARK-45184][SQL][DOCS][TESTS] Remove orphaned error class documents

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #42952:
URL: https://github.com/apache/spark/pull/42952#issuecomment-1722674085

   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] cloud-fan closed pull request #42952: [SPARK-45184][SQL][DOCS][TESTS] Remove orphaned error class documents

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan closed pull request #42952: [SPARK-45184][SQL][DOCS][TESTS] Remove orphaned error class documents
URL: https://github.com/apache/spark/pull/42952


-- 
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