You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by we...@apache.org on 2019/04/10 08:58:35 UTC
[spark] branch master updated: [SPARK-24872] Replace taking the
$symbol with $sqlOperator in BinaryOperator's toString method
This is an automated email from the ASF dual-hosted git repository.
wenchen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 85e5d4f [SPARK-24872] Replace taking the $symbol with $sqlOperator in BinaryOperator's toString method
85e5d4f is described below
commit 85e5d4f141eedd571dfa0dcdabedced19736a351
Author: 韩田田00222924 <ha...@zte.com.cn>
AuthorDate: Wed Apr 10 16:58:01 2019 +0800
[SPARK-24872] Replace taking the $symbol with $sqlOperator in BinaryOperator's toString method
## What changes were proposed in this pull request?
For BinaryOperator's toString method, it's better to use `$sqlOperator` instead of `$symbol`.
## How was this patch tested?
We can test this patch with unit tests.
Please review http://spark.apache.org/contributing.html before opening a pull request.
Closes #21826 from httfighter/SPARK-24872.
Authored-by: 韩田田00222924 <ha...@zte.com.cn>
Signed-off-by: Wenchen Fan <we...@databricks.com>
---
.../org/apache/spark/sql/catalyst/expressions/Expression.scala | 2 +-
.../apache/spark/sql/catalyst/expressions/PredicateSuite.scala | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala
index d5d1195..2cd84b5 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala
@@ -627,7 +627,7 @@ abstract class BinaryOperator extends BinaryExpression with ExpectsInputTypes {
def sqlOperator: String = symbol
- override def toString: String = s"($left $symbol $right)"
+ override def toString: String = s"($left $sqlOperator $right)"
override def inputTypes: Seq[AbstractDataType] = Seq(inputType, inputType)
diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/PredicateSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/PredicateSuite.scala
index e38bdeb..9b6896f 100644
--- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/PredicateSuite.scala
+++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/PredicateSuite.scala
@@ -27,6 +27,7 @@ import org.apache.spark.sql.catalyst.{CatalystTypeConverters, InternalRow}
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult
import org.apache.spark.sql.catalyst.encoders.ExamplePointUDT
import org.apache.spark.sql.catalyst.expressions.codegen.CodegenContext
+import org.apache.spark.sql.catalyst.parser.CatalystSqlParser
import org.apache.spark.sql.catalyst.util.{ArrayData, GenericArrayData}
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.types._
@@ -513,4 +514,11 @@ class PredicateSuite extends SparkFunSuite with ExpressionEvalHelper {
interpreted.initialize(0)
assert(interpreted.eval(new UnsafeRow()))
}
+
+ test("SPARK-24872: Replace taking the $symbol with $sqlOperator in BinaryOperator's" +
+ " toString method") {
+ val expression = CatalystSqlParser.parseExpression("id=1 or id=2").toString()
+ val expected = "(('id = 1) OR ('id = 2))"
+ assert(expression == expected)
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org