tagged [scala]

How do I check for equality using Spark Dataframe without SQL Query?

How do I check for equality using Spark Dataframe without SQL Query? I want to select a column that equals to a certain value. I am doing this in scala and having a little trouble. Heres my code this ...

How to print the contents of RDD?

How to print the contents of RDD? I'm attempting to print the contents of a collection to the Spark console. I have a type: And I use the command: But this is printed : > res1: org.apache.spark.rdd.RD...

17 Apr at 19:38

Editor does not contain a main type

Editor does not contain a main type Just going through the sample Scala code on Scala website, but encountered an annoying error when trying to run it. Here's the code: [http://www.scala-lang.org/node...

12 Mar at 09:24

Generics in Scala: implementing an interface/trait twice?

Generics in Scala: implementing an interface/trait twice? Given a generic interface such as the following I can in C# create a class that implements I twice (or more) with different types supplied for...

27 Sep at 07:37

How to list all cassandra tables

How to list all cassandra tables There are many tables in cassandra database, which contain column titled user_id. The values user_id are referred to user stored in table users. As some users are dele...

What is the apply function in Scala?

What is the apply function in Scala? I never understood it from the contrived unmarshalling and verbing nouns ( an `AddTwo` class has an `apply` that adds two!) examples. I understand that it's syntac...

16 Mar at 12:36

Algorithm to calculate the number of combinations to form 100

Algorithm to calculate the number of combinations to form 100 I am struck in a tricky situation where I need to calculate the number of combinations to form 100 based on different factors. Those are -...

20 Jun at 09:12

Scala check if element is present in a list

Scala check if element is present in a list I need to check if a string is present in a list, and call a function which accepts a boolean accordingly. Is it possible to achieve this with a one liner? ...

10 Jan at 21:30

How to pattern match using regular expression in Scala?

How to pattern match using regular expression in Scala? I would like to be able to find a match between the first letter of a word, and one of the letters in a group such as "ABC". In pseudocode, this...

21 Feb at 11:11

Scala list concatenation, ::: vs ++

Scala list concatenation, ::: vs ++ Is there any difference between `:::` and `++` for concatenating lists in Scala? From [the documentation](http://www.scala-lang.org/api/current/index.html#scala.col...

1 May at 08:24

ScalaTest in sbt: is there a way to run a single test without tags?

ScalaTest in sbt: is there a way to run a single test without tags? I know that a single test can be ran by running, in sbt, Is there a way of telling sbt/scalatest to run a single test without tags? ...

29 Jan at 09:33

get min and max from a specific column scala spark dataframe

get min and max from a specific column scala spark dataframe I would like to access to the min and max of a specific column from my dataframe but I don't have the header of the column, just its number...

5 Apr at 13:15

In Scala, how can I pass null to a Java method that expects Long?

In Scala, how can I pass null to a Java method that expects Long? I have a Java method that accepts a Long value: I understand that the Scala null does not extend any of the value types, including Lon...

6 Oct at 00:53

Print the data in ResultSet along with column names

Print the data in ResultSet along with column names I am retrieving columns names from a SQL database through Java. I know I can retrieve columns names from `ResultSet` too. So I have this sql query T...

8 May at 16:45

How to create a DataFrame from a text file in Spark

How to create a DataFrame from a text file in Spark I have a text file on HDFS and I want to convert it to a Data Frame in Spark. I am using the Spark Context to load the file and then try to generate...

Best way to parse command-line parameters?

Best way to parse command-line parameters? What's the best way to parse command-line parameters in Scala? I personally prefer something lightweight that does not require external jar. Related: - [How ...

How to use scalax.io.CommandLineParser?

How to use scalax.io.CommandLineParser? I want to create a class that takes string array as a constructor argument and has command line option values as members vals. Something like below, but I don't...

30 Oct at 20:56

Get item in the list in Scala?

Get item in the list in Scala? How in the world do you get just an element at index from the List in scala? I tried `get(i)`, and `[i]` - nothing works. Googling only returns how to "find" an element ...

17 Feb at 03:55

What is the difference between Scala's case class and class?

What is the difference between Scala's case class and class? I searched in Google to find the differences between a `case class` and a `class`. Everyone mentions that when you want to do pattern match...

Is there a way to have tuples with named fields in Scala, similar to anonymous classes in C#?

Is there a way to have tuples with named fields in Scala, similar to anonymous classes in C#? See: [Can I specify a meaningful name for an anonymous class in C#?](https://stackoverflow.com/questions/7...

23 May at 12:26

How much is there to LINQ?

How much is there to LINQ? I'm looking into LINQ and the query language appears (at least on the surface) to be nothing more than an implementation of map and/or list comprehensions as found in Haskel...

13 Sep at 17:0

Fetching distinct values on a column using Spark DataFrame

Fetching distinct values on a column using Spark DataFrame Using Spark 1.6.1 version I need to fetch distinct values on a column and then perform some specific transformation on top of it. The column ...

How to use java.String.format in Scala?

How to use java.String.format in Scala? I am trying to use a `.format` method of a string. But if I place %1, %2, etc. in the string, java.util.UnknownFormatConversionException is thrown pointing to a...

25 Jul at 19:7

Install sbt on ubuntu

Install sbt on ubuntu I have installed sbt on Ubuntu. However, whenever I try to launch sbt (from the same directory where sbt is located) it does not work: ``` No command 'sbt' found, did you mean: C...

4 Jul at 06:59

How do I break out of a loop in Scala?

How do I break out of a loop in Scala? How do I break out a loop? How do I turn nested for loops in

2 Nov at 22:35