beliefer commented on a change in pull request #35494:
URL: https://github.com/apache/spark/pull/35494#discussion_r805451395



##########
File path: 
sql/catalyst/src/main/java/org/apache/spark/sql/connector/expressions/GeneralSQLExpression.java
##########
@@ -22,20 +22,34 @@
 import org.apache.spark.annotation.Evolving;
 
 /**
- * The general SQL string corresponding to expression.
+ * The general V2 expression corresponding to V1 expression.

Review comment:
       I have tested, the SQL syntax is different between databases.
   So ,we try to use V2 expression to replace SQL string.

##########
File path: 
sql/catalyst/src/main/java/org/apache/spark/sql/connector/expressions/GeneralSQLExpression.java
##########
@@ -22,20 +22,34 @@
 import org.apache.spark.annotation.Evolving;
 
 /**
- * The general SQL string corresponding to expression.
+ * The general V2 expression corresponding to V1 expression.
  *
  * @since 3.3.0
  */
 @Evolving
 public class GeneralSQLExpression implements Expression, Serializable {

Review comment:
       We will use V2 expression to replace SQL string.

##########
File path: sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala
##########
@@ -194,6 +194,66 @@ abstract class JdbcDialect extends Serializable with 
Logging{
     case _ => value
   }
 
+  protected final val BINARY_COMPARISON = Set("=", "!=", "<=>", "<", "<=", 
">", ">=",
+    "+", "-", "*", "/", "%", "&&", "||", "AND", "OR", "&", "|", "^")
+
+  /**
+   * Converts V2 expression to String representing a SQL expression.
+   * @param expr The V2 expression to be converted.
+   * @return Converted value.
+   */
+  @Since("3.3.0")
+  def compileExpression(expr: Expression): Option[String] = expr match {
+    case l @ LiteralValue(_, _) => Some(l.toString)

Review comment:
       Yes. Thank you for your reminder.
   But `l: Literal` used in many places.
   
https://github.com/apache/spark/blob/1c0793a75b74ac7b55631e61d9e827e93647f1d2/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/DecimalPrecision.scala#L325

##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/catalyst/util/ExpressionSQLBuilder.scala
##########
@@ -67,3 +122,8 @@ class ExpressionSQLBuilder(e: Expression) {
     case _ => None
   }
 }
+
+object GeneralExpression {
+  def apply(expressions: Array[V2Expression], name: String = "UNDEFINED"): 
GeneralSQLExpression =
+    new GeneralSQLExpression(name, expressions)

Review comment:
       I'm sorry. I don't understand what you mean.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to