-1

Every spark program has this line import spark.implicits._. When I looked online to understand the use of "implicits" in scala, I got this definition:

Scala "implicits" allow you to omit calling methods or referencing variables directly but instead rely on the compiler to make the connections for you

I understand the definition but it brings me the below doubts.

Isn't it the same with any other import statement ? Every import statement would bring the functions/options/methods we would like to use them in the code. If implicits are different to regular import statement, what do they bring to the table and how are they different ? Could anyone explain the real use case of implicits parameters & functions in scala ?

Mario Galic
  • 47,285
  • 6
  • 56
  • 98
Metadata
  • 2,127
  • 9
  • 56
  • 127

1 Answers1

0

Isn't it the same with any other import statement ?

It is. implicits in spark.implicits is just a name, and

import spark.implicits._

is only unusual because it imports members of an instance, which many other languages with something like import can't do (but Scala can).

If you look at docs for implicits you'll see its members are marked as implicit which is what actually makes them implicit.

Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487