Bruce Robbins created SPARK-39093: ------------------------------------- Summary: Dividing interval by integral can result in codegen compilation error Key: SPARK-39093 URL: https://issues.apache.org/jira/browse/SPARK-39093 Project: Spark Issue Type: Bug Components: SQL Affects Versions: 3.4.0 Reporter: Bruce Robbins
Assume this data: {noformat} create or replace temp view v1 as select * FROM VALUES (interval '10' months, interval '10' day, 2) as v1(period, duration, num); cache table v1; {noformat} These two queries work: {noformat} spark-sql> select period/num from v1; 0-5 Time taken: 0.143 seconds, Fetched 1 row(s) {noformat} {noformat} spark-sql> select duration/num from v1; 5 00:00:00.000000000 Time taken: 0.094 seconds, Fetched 1 row(s) {noformat} However, these two queries get a codegen compilation error: {noformat} spark-sql> select period/(num + 3) from v1; 22/05/03 08:56:37 ERROR CodeGenerator: failed to compile: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 40, Column 44: Expression "project_value_2" is not an rvalue ... 22/05/03 08:56:37 WARN UnsafeProjection: Expr codegen error and falling back to interpreter mode ... 0-2 Time taken: 0.149 seconds, Fetched 1 row(s) {noformat} {noformat} spark-sql> select duration/(num + 3) from v1; 22/05/03 08:57:29 ERROR CodeGenerator: failed to compile: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 40, Column 54: Expression "project_value_2" is not an rvalue ... 22/05/03 08:57:29 WARN UnsafeProjection: Expr codegen error and falling back to interpreter mode ... 2 00:00:00.000000000 Time taken: 0.089 seconds, Fetched 1 row(s) {noformat} Note that both queries still return a result because Spark falls back on interpreting the divide expression (so I marked this as "minor"). -- This message was sent by Atlassian Jira (v8.20.7#820007) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org