Class GeneralScalarExpression

Object
org.apache.spark.sql.internal.connector.ExpressionWithToString
org.apache.spark.sql.connector.expressions.GeneralScalarExpression
All Implemented Interfaces:
Serializable, Expression
Direct Known Subclasses:
Predicate

@Evolving public class GeneralScalarExpression extends org.apache.spark.sql.internal.connector.ExpressionWithToString
The general representation of SQL scalar expressions, which contains the upper-cased expression name and all the children expressions. Please also see Predicate for the supported predicate expressions.

The currently supported SQL scalar expressions:

  1. Name: +
    • SQL semantic: expr1 + expr2
    • Since version: 3.3.0
  2. Name: -
    • SQL semantic: expr1 - expr2 or - expr
    • Since version: 3.3.0
  3. Name: *
    • SQL semantic: expr1 * expr2
    • Since version: 3.3.0
  4. Name: /
    • SQL semantic: expr1 / expr2
    • Since version: 3.3.0
  5. Name: %
    • SQL semantic: expr1 % expr2
    • Since version: 3.3.0
  6. Name: &
    • SQL semantic: expr1 & expr2
    • Since version: 3.3.0
  7. Name: |
    • SQL semantic: expr1 | expr2
    • Since version: 3.3.0
  8. Name: ^
    • SQL semantic: expr1 ^ expr2
    • Since version: 3.3.0
  9. Name: ~
    • SQL semantic: ~ expr
    • Since version: 3.3.0
  10. Name: CASE_WHEN
    • SQL semantic: CASE WHEN expr1 THEN expr2 [WHEN expr3 THEN expr4]* [ELSE expr5] END
    • Since version: 3.3.0
  11. Name: ABS
    • SQL semantic: ABS(expr)
    • Since version: 3.3.0
  12. Name: COALESCE
    • SQL semantic: COALESCE(expr1, expr2)
    • Since version: 3.3.0
  13. Name: GREATEST
    • SQL semantic: GREATEST(expr, ...)
    • Since version: 3.4.0
  14. Name: LEAST
    • SQL semantic: LEAST(expr, ...)
    • Since version: 3.4.0
  15. Name: RAND
    • SQL semantic: RAND([seed])
    • Since version: 3.4.0
  16. Name: LOG
    • SQL semantic: LOG(base, expr)
    • Since version: 3.4.0
  17. Name: LOG10
    • SQL semantic: LOG10(expr)
    • Since version: 3.4.0
  18. Name: LOG2
    • SQL semantic: LOG2(expr)
    • Since version: 3.4.0
  19. Name: LN
    • SQL semantic: LN(expr)
    • Since version: 3.3.0
  20. Name: EXP
    • SQL semantic: EXP(expr)
    • Since version: 3.3.0
  21. Name: POWER
    • SQL semantic: POWER(expr, number)
    • Since version: 3.3.0
  22. Name: SQRT
    • SQL semantic: SQRT(expr)
    • Since version: 3.3.0
  23. Name: FLOOR
    • SQL semantic: FLOOR(expr)
    • Since version: 3.3.0
  24. Name: CEIL
    • SQL semantic: CEIL(expr)
    • Since version: 3.3.0
  25. Name: ROUND
    • SQL semantic: ROUND(expr, [scale])
    • Since version: 3.4.0
  26. Name: SIN
    • SQL semantic: SIN(expr)
    • Since version: 3.4.0
  27. Name: SINH
    • SQL semantic: SINH(expr)
    • Since version: 3.4.0
  28. Name: COS
    • SQL semantic: COS(expr)
    • Since version: 3.4.0
  29. Name: COSH
    • SQL semantic: COSH(expr)
    • Since version: 3.4.0
  30. Name: TAN
    • SQL semantic: TAN(expr)
    • Since version: 3.4.0
  31. Name: TANH
    • SQL semantic: TANH(expr)
    • Since version: 3.4.0
  32. Name: COT
    • SQL semantic: COT(expr)
    • Since version: 3.4.0
  33. Name: ASIN
    • SQL semantic: ASIN(expr)
    • Since version: 3.4.0
  34. Name: ASINH
    • SQL semantic: ASINH(expr)
    • Since version: 3.4.0
  35. Name: ACOS
    • SQL semantic: ACOS(expr)
    • Since version: 3.4.0
  36. Name: ACOSH
    • SQL semantic: ACOSH(expr)
    • Since version: 3.4.0
  37. Name: ATAN
    • SQL semantic: ATAN(expr)
    • Since version: 3.4.0
  38. Name: ATANH
    • SQL semantic: ATANH(expr)
    • Since version: 3.4.0
  39. Name: ATAN2
    • SQL semantic: ATAN2(exprY, exprX)
    • Since version: 3.4.0
  40. Name: CBRT
    • SQL semantic: CBRT(expr)
    • Since version: 3.4.0
  41. Name: DEGREES
    • SQL semantic: DEGREES(expr)
    • Since version: 3.4.0
  42. Name: RADIANS
    • SQL semantic: RADIANS(expr)
    • Since version: 3.4.0
  43. Name: SIGN
    • SQL semantic: SIGN(expr)
    • Since version: 3.4.0
  44. Name: WIDTH_BUCKET
    • SQL semantic: WIDTH_BUCKET(expr)
    • Since version: 3.3.0
  45. Name: SUBSTRING
    • SQL semantic: SUBSTRING(str, pos[, len])
    • Since version: 3.4.0
  46. Name: UPPER
    • SQL semantic: UPPER(expr)
    • Since version: 3.4.0
  47. Name: LOWER
    • SQL semantic: LOWER(expr)
    • Since version: 3.4.0
  48. Name: TRANSLATE
    • SQL semantic: TRANSLATE(input, from, to)
    • Since version: 3.4.0
  49. Name: TRIM
    • SQL semantic: TRIM(src, trim)
    • Since version: 3.4.0
  50. Name: LTRIM
    • SQL semantic: LTRIM(src, trim)
    • Since version: 3.4.0
  51. Name: RTRIM
    • SQL semantic: RTRIM(src, trim)
    • Since version: 3.4.0
  52. Name: BIT_LENGTH
    • SQL semantic: BIT_LENGTH(src)
    • Since version: 3.4.0
  53. Name: CHAR_LENGTH
    • SQL semantic: CHAR_LENGTH(src)
    • Since version: 3.4.0
  54. Name: CONCAT
    • SQL semantic: CONCAT(col1, col2, ..., colN)
    • Since version: 3.4.0
  55. Name: OVERLAY
    • SQL semantic: OVERLAY(string, replace, position[, length])
    • Since version: 3.4.0
  56. Name: DATE_ADD
    • SQL semantic: DATE_ADD(start_date, num_days)
    • Since version: 3.4.0
  57. Name: DATE_DIFF
    • SQL semantic: DATE_DIFF(end_date, start_date)
    • Since version: 3.4.0
  58. Name: TRUNC
    • SQL semantic: TRUNC(date, format)
    • Since version: 3.4.0
  59. Name: AES_ENCRYPT
    • SQL semantic: AES_ENCRYPT(expr, key[, mode[, padding]])
    • Since version: 3.4.0
  60. Name: AES_DECRYPT
    • SQL semantic: AES_DECRYPT(expr, key[, mode[, padding]])
    • Since version: 3.4.0
  61. Name: SHA1
    • SQL semantic: SHA1(expr)
    • Since version: 3.4.0
  62. Name: SHA2
    • SQL semantic: SHA2(expr, bitLength)
    • Since version: 3.4.0
  63. Name: MD5
    • SQL semantic: MD5(expr)
    • Since version: 3.4.0
  64. Name: CRC32
    • SQL semantic: CRC32(expr)
    • Since version: 3.4.0
Note: SQL semantic conforms ANSI standard, so some expressions are not supported when ANSI off, including: add, subtract, multiply, divide, remainder, pmod.
Since:
3.3.0
See Also:
  • Constructor Details

    • GeneralScalarExpression

      public GeneralScalarExpression(String name, Expression[] children)
  • Method Details

    • name

      public String name()
    • children

      public Expression[] children()
      Description copied from interface: Expression
      Returns an array of the children of this node. Children should not change.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object