Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1369,20 +1369,28 @@ 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().getConstructor().newInstance().asInstanceOf[GeneratedClass], codeStats)
}

private def logGeneratedCode(code: CodeAndComment): Unit = {
val maxLines = SQLConf.get.loggingMaxLinesForCodegen
if (Utils.isTesting) {
// log as ERROR so that it can be always logged in UT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since its clear what the code is, I personally think we don't need this comment.

logError(s"\n${CodeFormatter.format(code, maxLines)}")
} else {
logInfo(s"\n${CodeFormatter.format(code, maxLines)}")
}
}

/**
* Returns the bytecode statistics (max method bytecode size, max constant pool size, and
* # of inner classes) of generated classes by inspecting Janino classes.
Expand Down