Search code examples
scalaapache-sparkfractions

Problems importing lib in Spark


I was looking for some library providing Fractions for Spark + Scala and found this link .

I am not sure, if I can use it or that's something unavailable for me? In spark-shell I'm writing import org.apache.commons.math4.fraction and getting

<console>:23: error: object math4 is not a member of package org.apache.commons
       import org.apache.commons.math4.fraction

Though I can import org.apache.commons without any troubles.

Could you please explain me what's wrong? Or maybe you could recommend some other lib for Fractions?

Thank you in advance.


Solution

  • You need to download the jar file and use while running the spark-shell

    Download the jar file from here.

    Now extract in some location

    tar xvf <location of tar/ zip files>
    

    Now start the spark-shell as

    ./spark-shell --jars path to this jar file commons-math3-3.6.1.jar
    

    And use as

    import org.apache.commons.math3.fraction