Skip to content
Snippets Groups Projects
  • Cheng Lian's avatar
    d9efe63e
    [SPARK-12799] Simplify various string output for expressions · d9efe63e
    Cheng Lian authored
    This PR introduces several major changes:
    
    1. Replacing `Expression.prettyString` with `Expression.sql`
    
       The `prettyString` method is mostly an internal, developer faced facility for debugging purposes, and shouldn't be exposed to users.
    
    1. Using SQL-like representation as column names for selected fields that are not named expression (back-ticks and double quotes should be removed)
    
       Before, we were using `prettyString` as column names when possible, and sometimes the result column names can be weird.  Here are several examples:
    
       Expression         | `prettyString` | `sql`      | Note
       ------------------ | -------------- | ---------- | ---------------
       `a && b`           | `a && b`       | `a AND b`  |
       `a.getField("f")`  | `a[f]`         | `a.f`      | `a` is a struct
    
    1. Adding trait `NonSQLExpression` extending from `Expression` for expressions that don't have a SQL representation (e.g. Scala UDF/UDAF and Java/Scala object expressions used for encoders)
    
       `NonSQLExpression.sql` may return an arbitrary user facing string representation of the expression.
    
    Author: Cheng Lian <lian@databricks.com>
    
    Closes #10757 from liancheng/spark-12799.simplify-expression-string-methods.
    d9efe63e
    History
    [SPARK-12799] Simplify various string output for expressions
    Cheng Lian authored
    This PR introduces several major changes:
    
    1. Replacing `Expression.prettyString` with `Expression.sql`
    
       The `prettyString` method is mostly an internal, developer faced facility for debugging purposes, and shouldn't be exposed to users.
    
    1. Using SQL-like representation as column names for selected fields that are not named expression (back-ticks and double quotes should be removed)
    
       Before, we were using `prettyString` as column names when possible, and sometimes the result column names can be weird.  Here are several examples:
    
       Expression         | `prettyString` | `sql`      | Note
       ------------------ | -------------- | ---------- | ---------------
       `a && b`           | `a && b`       | `a AND b`  |
       `a.getField("f")`  | `a[f]`         | `a.f`      | `a` is a struct
    
    1. Adding trait `NonSQLExpression` extending from `Expression` for expressions that don't have a SQL representation (e.g. Scala UDF/UDAF and Java/Scala object expressions used for encoders)
    
       `NonSQLExpression.sql` may return an arbitrary user facing string representation of the expression.
    
    Author: Cheng Lian <lian@databricks.com>
    
    Closes #10757 from liancheng/spark-12799.simplify-expression-string-methods.