- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2024 06:01 AM
There isn't a configuration that can be set to True/False and control this behavior for some statements.
This output is part of Databrick's interactive notebook design, where all evaluated statements—such as imports, variable declarations, and expressions—are displayed to help users keep track of variable states and imports in each cell.
As a workaround, you could manually control this indirectly with a { ... ; () } structure, as returning Unit suppresses implicit output. e.g.:
{
// Imports
import java.time.LocalDate
import scala.util.Random
// Variable declarations
val currentDate = LocalDate.now()
val randomValue = Random.nextInt(100)
// Explicit outputs
println(s"Today's date: $currentDate")
println(s"Random value: $randomValue")
// Suppress implicit output
()
}
Using the { ... ; () } structure does not impact code execution: imports, variable declarations, and other statements will still execute as usual but won't produce any implicit output; so this way, you may control what is displayed in the output of the Databricks notebook cell. Println produces explicit output.
Hope it helps.