yaooqinn commented on PR #46757: URL: https://github.com/apache/spark/pull/46757#issuecomment-2137314651
```sql spark-sql (default)> SELECT typeof(!true::string || ''), !true::string || ''; boolean false spark-sql (default)> explain SELECT typeof(!true::string || ''), !true::string || ''; == Physical Plan == *(1) Project [boolean AS typeof((NOT concat(CAST(true AS STRING), )))#102, false AS (NOT concat(CAST(true AS STRING), ))#103] +- *(1) Scan OneRowRelation[] spark-sql (default)> SELECT !'tr' || 'ue'; false ``` Hi @cloud-fan I created a test case with `!` and `||` as they both accept string and boolean values. Currently, the expression `!a || b` concat `a` and `b`, and then apply `!`, a.k.a. `!(a || b)`, produces boolean values at last If we move `!` to the level `+-~` belongs, the expression `!a || b` performs like `(!a) || b`, produces string values at last. I don't think we can fix this without any breaking change. -- 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]
