You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "Hisoka-X (via GitHub)" <gi...@apache.org> on 2023/07/05 15:49:08 UTC

[GitHub] [spark] Hisoka-X opened a new pull request, #41865: [SPARK-44268][CORE][TEST][FOLLOWUP] Add test to generate `sql-error-conditions` doc automatic

Hisoka-X opened a new pull request, #41865:
URL: https://github.com/apache/spark/pull/41865

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'core/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   This is a follow up PR for #41813, change test to automatic generate `sql-error-conditions` doc. Like other GOLDEN_FILES test, if the doc not match will report a error during test.
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   
   
   ### Why are the changes needed?
   1. make sure the `error-classes.json` sync with doc
   2. and developer sync doc easier.
   
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   
   ### Does this PR introduce _any_ user-facing change?
   No
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   
   
   ### How was this patch tested?
   add new test.
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   


-- 
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 pull request #41865: [SPARK-44268][CORE][TEST][FOLLOWUP] Add test to generate `sql-error-conditions` doc automatic

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

   Thanks @HyukjinKwon @MaxGekk @beliefer 


-- 
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 #41865: [SPARK-44268][CORE][TEST][FOLLOWUP] Add test to generate `sql-error-conditions` doc automatic

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


##########
docs/sql-error-conditions-invalid-format-error-class.md:
##########
@@ -55,7 +55,7 @@ Thousands separators (, or G) may not appear after the decimal point in the numb
 
 ## UNEXPECTED_TOKEN
 
-Found the unexpected `<token>` in the format string; the structure of the format string must match: `[MI|S]` `[$]` `[0|9|G|,]*` `[.|D]` `[0|9]*` `[$]` `[PR|MI|S]`.
+Found the unexpected `<token>` in the format string; the structure of the format string must match: [MI|S] [$] [0|9|G|,]* [.|D] [0|9]* [$] [PR|MI|S].

Review Comment:
   This one a little special, can I add "\`" quote in `error-classes.json` to make sure `[MI|S]` has \`[MI|S]\`?



-- 
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] HyukjinKwon closed pull request #41865: [SPARK-44268][CORE][TEST][FOLLOWUP] Add test to generate `sql-error-conditions` doc automatic

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon closed pull request #41865: [SPARK-44268][CORE][TEST][FOLLOWUP] Add test to generate `sql-error-conditions` doc automatic
URL: https://github.com/apache/spark/pull/41865


-- 
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 #41865: [SPARK-44268][CORE][TEST][FOLLOWUP] Add test to generate `sql-error-conditions` doc automatic

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


##########
core/src/test/scala/org/apache/spark/SparkThrowableSuite.scala:
##########
@@ -141,54 +149,167 @@ class SparkThrowableSuite extends SparkFunSuite {
     checkIfUnique(messageFormats)
   }
 
-  test("SPARK-44268: Error classes match with document") {
-    val sqlstateDoc = "sql-error-conditions-sqlstates.md"
+  test("Error classes match with document") {
     val errors = errorReader.errorInfoMap
-    val errorDocPaths = getWorkspaceFilePath("docs").toFile
-      .listFiles(_.getName.startsWith("sql-error-conditions-"))
-      .filter(!_.getName.equals(sqlstateDoc))
-      .map(f => IOUtils.toString(f.toURI, StandardCharsets.UTF_8)).map(_.split("\n"))
-    // check the error classes in document should be in error-classes.json
-    val linkInDocRegex = "\\[(.*)\\]\\((.*)\\)".r
-    val commonErrorsInDoc = IOUtils.toString(getWorkspaceFilePath("docs",
-      "sql-error-conditions.md").toUri, StandardCharsets.UTF_8).split("\n")
-      .filter(_.startsWith("###")).map(s => s.replace("###", "").trim)
-      .filter(linkInDocRegex.findFirstMatchIn(_).isEmpty)
-
-    commonErrorsInDoc.foreach(s => assert(errors.contains(s),
-      s"Error class: $s is not in error-classes.json"))
-
-    val titlePrefix = "title:"
-    val errorsInDoc = errorDocPaths.map(lines => {
-      val errorClass = lines.filter(_.startsWith(titlePrefix))
-        .map(s => s.replace("error class", "").replace(titlePrefix, "").trim).head
-      assert(errors.contains(errorClass), s"Error class: $errorClass is not in error-classes.json")
-      val subClasses = lines.filter(_.startsWith("##")).map(s => s.replace("##", "").trim)
-        .map { s =>
-          assert(errors(errorClass).subClass.get.contains(s),
-            s"Error class: $errorClass does not contain sub class: $s in error-classes.json")
-          s
+    def quoteParameter(content: String): String = {
+      "(?<!MAP|STRUCT|ARRAY)<(.*?)>".r.replaceAllIn(content, (m: Regex.Match) => {

Review Comment:
   @MaxGekk I updated the rule, fix all problems you metioned. Please check the rule is ok or not. Thanks.



-- 
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 pull request #41865: [SPARK-44268][CORE][TEST][FOLLOWUP] Add test to generate `sql-error-conditions` doc automatic

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

   cc @MaxGekk @beliefer


-- 
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] MaxGekk commented on a diff in pull request #41865: [SPARK-44268][CORE][TEST][FOLLOWUP] Add test to generate `sql-error-conditions` doc automatic

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


##########
docs/sql-error-conditions-invalid-format-error-class.md:
##########
@@ -55,7 +55,7 @@ Thousands separators (, or G) may not appear after the decimal point in the numb
 
 ## UNEXPECTED_TOKEN
 
-Found the unexpected `<token>` in the format string; the structure of the format string must match: `[MI|S]` `[$]` `[0|9|G|,]*` `[.|D]` `[0|9]*` `[$]` `[PR|MI|S]`.
+Found the unexpected `<token>` in the format string; the structure of the format string must match: [MI|S] [$] [0|9|G|,]* [.|D] [0|9]* [$] [PR|MI|S].

Review Comment:
   Yep



-- 
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] HyukjinKwon commented on pull request #41865: [SPARK-44268][CORE][TEST][FOLLOWUP] Add test to generate `sql-error-conditions` doc automatic

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

   Merged 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] MaxGekk commented on a diff in pull request #41865: [SPARK-44268][CORE][TEST][FOLLOWUP] Add test to generate `sql-error-conditions` doc automatic

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


##########
docs/sql-error-conditions-datatype-mismatch-error-class.md:
##########
@@ -176,16 +174,13 @@ A range window frame cannot be used in an unordered window specification.
 ## SEQUENCE_WRONG_INPUT_TYPES
 
 `<functionName>` uses the wrong parameter type. The parameter type must conform to:
-
 1. The start and stop expressions must resolve to the same type.
-
 2. If start and stop expressions resolve to the `<startType>` type, then the step expression must resolve to the `<stepType>` type.
-
 3. Otherwise, if start and stop expressions resolve to the `<otherStartType>` type, then the step expression must resolve to the same type.
 
 ## SPECIFIED_WINDOW_FRAME_DIFF_TYPES
 
-Window frame bounds `<lower>` and `<upper>` do not have the same type: `<lowerType>` <> `<upperType>`.
+Window frame bounds `<lower>` and `<upper>` do not have the same type: `<lowerType>` `<>` `<upperType>`.

Review Comment:
   Should leave <> as is?



##########
docs/sql-error-conditions-invalid-parameter-value-error-class.md:
##########
@@ -51,6 +51,6 @@ Expects group index between 0 and `<groupCount>`, but got `<groupIndex>`.
 
 ## ZERO_INDEX
 
-expects `%1$`, `%2$` and so on, but got `%0$`.
+expects %1$, %2$ and so on, but got %0$.

Review Comment:
   This one should have quotes, shouldn't it?



##########
docs/sql-error-conditions-incomplete-type-definition-error-class.md:
##########
@@ -31,10 +31,10 @@ The definition of "ARRAY" type is incomplete. You must provide an element type.
 
 ## MAP
 
-The definition of "MAP" type is incomplete. You must provide a key type and a value type. For example: "MAP<TIMESTAMP, INT>".
+The definition of "MAP" type is incomplete. You must provide a key type and a value type. For example: "MAP`<TIMESTAMP, INT>`".

Review Comment:
   Similar issue here, don't quote <TIMESTAMP, INT>



##########
docs/sql-error-conditions-datatype-mismatch-error-class.md:
##########
@@ -205,7 +200,7 @@ The lower bound of a window frame must be `<comparison>` to the upper bound.
 
 ## STACK_COLUMN_DIFF_TYPES
 
-The data type of the column (`<columnIndex>`) do not have the same type: `<leftType>` (`<leftParamIndex>`) <> `<rightType>` (`<rightParamIndex>`).
+The data type of the column (`<columnIndex>`) do not have the same type: `<leftType>` (`<leftParamIndex>`) `<>` `<rightType>` (`<rightParamIndex>`).

Review Comment:
   ditto: don't touch <>



-- 
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 #41865: [SPARK-44268][CORE][TEST][FOLLOWUP] Add test to generate `sql-error-conditions` doc automatic

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


##########
docs/sql-error-conditions-invalid-format-error-class.md:
##########
@@ -55,7 +55,7 @@ Thousands separators (, or G) may not appear after the decimal point in the numb
 
 ## UNEXPECTED_TOKEN
 
-Found the unexpected `<token>` in the format string; the structure of the format string must match: `[MI|S]` `[$]` `[0|9|G|,]*` `[.|D]` `[0|9]*` `[$]` `[PR|MI|S]`.
+Found the unexpected `<token>` in the format string; the structure of the format string must match: [MI|S] [$] [0|9|G|,]* [.|D] [0|9]* [$] [PR|MI|S].

Review Comment:
   This one a little special, can I add "\`" quote in `error-classes.json` to make sure `[MI|S]` has \`[MI|S]\`



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