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/03/30 06:15:01 UTC
[GitHub] [spark] cloud-fan commented on a change in pull request #35992: [SPARK-38676][SQL] Provide SQL query context in runtime error message of Add/Subtract/Multiply
cloud-fan commented on a change in pull request #35992:
URL: https://github.com/apache/spark/pull/35992#discussion_r838153800
##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/trees/TreeNodeSuite.scala
##########
@@ -856,4 +856,36 @@ class TreeNodeSuite extends SparkFunSuite with SQLHelper {
val node = Node(Set("second", "first"), Seq(Set(3, 1), Set(2, 1)))
assert(node.argString(10) == "{first, second}, [{1, 3}, {1, 2}]")
}
+
+ test("SPARK-38676: truncate before/after sql text if too long") {
+ val text =
+ """
+ |
+ |SELECT
+ |1234567890 + 1234567890 + 1234567890, cast('a'
+ |as /* comment */
+ |int), 1234567890 + 1234567890 + 1234567890
+ |as foo
+ |""".stripMargin
+ val origin = Origin(
+ line = Some(3),
+ startPosition = Some(38),
+ startIndex = Some(47),
+ stopIndex = Some(77),
+ sqlText = Some(text),
+ objectType = Some("VIEW"),
+ objectName = Some("some_view"))
+ val expected =
+ """
+ |== SQL of VIEW some_view(line 3, position 38) ==
+ |...7890 + 1234567890 + 1234567890, cast('a'
Review comment:
We can improve this later to also do truncation for the expression SQL string. For example, a better error message in this case is
```
== SQL of VIEW some_view(line 3, position 38) ==
...7890 + 1234567890 + 1234567890, cast('a'...int), 1234567890 + 1234567890 + 12345...
^^^^^^^^^^^^^^^
```
--
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