This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch branch-2.4
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-2.4 by this push:
     new 267d318  [SPARK-29165][SQL][TEST] Set log level of log generated code 
as ERROR in case of compile error on generated code in UT
267d318 is described below

commit 267d318d078e846f7a5186f1e33c86cfe3d43fa7
Author: Jungtaek Lim (HeartSaVioR) <kabh...@gmail.com>
AuthorDate: Thu Sep 19 11:47:47 2019 -0700

    [SPARK-29165][SQL][TEST] Set log level of log generated code as ERROR in 
case of compile error on generated code in UT
    
    ### What changes were proposed in this pull request?
    
    This patch proposes to change the log level of logging generated code in 
case of compile error being occurred in UT. This would help to investigate 
compilation issue of generated code easier, as currently we got exception 
message of line number but there's no generated code being logged actually (as 
in most cases of UT the threshold of log level is at least WARN).
    
    ### Why are the changes needed?
    
    This would help investigating issue on compilation error for generated code 
in UT.
    
    ### Does this PR introduce any user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    N/A
    
    Closes #25835 from 
HeartSaVioR/MINOR-always-log-generated-code-on-fail-to-compile-in-unit-testing.
    
    Authored-by: Jungtaek Lim (HeartSaVioR) <kabh...@gmail.com>
    Signed-off-by: Dongjoon Hyun <dh...@apple.com>
    (cherry picked from commit eee2e026bb4019020b492c54ba51a97df42b13c2)
    Signed-off-by: Dongjoon Hyun <dh...@apple.com>
---
 .../sql/catalyst/expressions/codegen/CodeGenerator.scala  | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
index 812877d..56a7d59 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
@@ -1293,20 +1293,27 @@ object CodeGenerator extends Logging {
       case e: InternalCompilerException =>
         val msg = s"failed to compile: $e"
         logError(msg, e)
-        val maxLines = SQLConf.get.loggingMaxLinesForCodegen
-        logInfo(s"\n${CodeFormatter.format(code, maxLines)}")
+        logGeneratedCode(code)
         throw new InternalCompilerException(msg, e)
       case e: CompileException =>
         val msg = s"failed to compile: $e"
         logError(msg, e)
-        val maxLines = SQLConf.get.loggingMaxLinesForCodegen
-        logInfo(s"\n${CodeFormatter.format(code, maxLines)}")
+        logGeneratedCode(code)
         throw new CompileException(msg, e.getLocation)
     }
 
     (evaluator.getClazz().newInstance().asInstanceOf[GeneratedClass], 
maxCodeSize)
   }
 
+  private def logGeneratedCode(code: CodeAndComment): Unit = {
+    val maxLines = SQLConf.get.loggingMaxLinesForCodegen
+    if (Utils.isTesting) {
+      logError(s"\n${CodeFormatter.format(code, maxLines)}")
+    } else {
+      logInfo(s"\n${CodeFormatter.format(code, maxLines)}")
+    }
+  }
+
   /**
    * Returns the max bytecode size of the generated functions by inspecting 
janino private fields.
    * Also, this method updates the metrics information.


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to