Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-14767

Codegen "no constructor found" errors with Maps inside case classes in Datasets

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Duplicate
    • 2.0.0
    • None
    • SQL
    • None

    Description

      When I have a `Map` inside a case class and am trying to use Datasets,
      the simplest operation throws an exception, because the generated code is looking for a constructor with `scala.collection.Map` whereas the constructor takes `scala.collection.immutable.Map`.

      To reproduce:

      case class Bug(bug: Map[String, String])
      
      val ds = Seq(Bug(Map("name" -> "dummy"))).toDS()
      
      ds.map { b =>
        b.bug.getOrElse("name", null)
      }.count()
      

      Stacktrace:

      Caused by: java.util.concurrent.ExecutionException: java.lang.Exception: failed to compile: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 163, Column 150: No applicable constructor/method found for actual parameters "scala.collection.Map"; candidates are: Bug(scala.collection.immutable.Map)"
      

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            brkyvz Burak Yavuz
            Votes:
            5 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment