Category "scala"

How to iterate over a List of numbers and check if there are pairs of numbers that add up to a given value using Scala?

I have to generate a list of prime numbers smaller than a given number and then find all pairs of the generated prime numbers that add up to that value. E.g. nu

Parsing JObject In Scala

I am using json4s for parsing a json object which gives me result like this: JObject(List((x,JArray(List(JString(x_value)))), (y,JArray(List(JString(y_value)))

Scala 3: Define a typeclass instance for an inner class

I am trying to define typeclass instances for an inner class. As a minimal example, I have code that looks like this: trait Typeclass[T] class Outer: class

Gatling compilation failed

I'm trying to build https://github.com/gatling/gatling but the compilation fails. The steps I undertook: Installed sbt using the documentation. Clone the githu

Spark scala how to remove the columns that are not in common between 2 dataframes

I have 2 dataframes, the first one has 53 columns and the second one has 132 column. I want to compare the 2 dataframes and remove all the columns that are not

How can I split string like key and value using scala in efficient way:

How can I split string like key and value using scala in efficient way: I would like to split below emp string into key value pair. var emp = "Map(employees -&g

Scala bulkcopy not working in Azure DAtabricks runtime 7.3LTS and above

My scala code that used to work fine with databricks runtime 5.5LTS is not working with runtime 7.3LTS and above. I have tried upgrading microsoft libraries acc

Handleing AskTimeoutException on Akka based application

I have the following HTTP-based application that routes every request to an Akka Actor which uses a long chain of Akka Actors to process the request. path("p

There is any objective reason why Scala differentiate fold and reduce functions?

Reduce can be an override fold that doesn't take the first element. I guess there is an answer to that design decision but I can't find it.

Error: A JNI error has occurred, please check your installation and try again in IntelliJ IDEA for Scala-Spark Program using SBT

import org.apache.spark.sql.SparkSession object RDDBroadcast extends App { val spark = SparkSession.builder() .appName("SparkByExamples.com") .maste

Scala.JS configuration for Scala 3?

I tried posting this question to Scala Users but no reply yet. How does one go about working with the new experimental Scala 3 with Scala.JS? I can’t find

Scala argument upper type bounds and overriding

I am trying to understand and incorporate upper bound types with overriding in my system, but have not been able to achieve it without some ugly code. I have th

Spark: retrieving old values of rows after casting made invalid input nulls

I am having trouble retrieving the old value before a cast of a column in spark. initially, all my inputs are strings and I want to cast the column num1 into a

java.lang.IllegalStateException: Error reading delta file, stateful spark structured streaming with kafka

We are running a stateful structured streaming job which reads from Kafka and writes to HDFS. And we are hitting this exception: 17/12/08 05:20:12 ERROR FileFor

Akka Typed - How to sent Terminated message to BehaviorTestKit

I'm trying to unit test my actor's handling of a "Terminated" message for a child actor. The code under test is something like this: case Terminated(termin

Better/Efficient way to filter out Spark Dataframe rows with multiple conditions

I have a dataframe look like this below id pub_date version unique_id c_id p_id type source lni001 20220301 1

Scala Doobie. Creating and Inserting into a Temp Table

I am relatively new to Scala and also new to Doobie. I am connecting to SQL Server 2014 and need to create a temp table and subsequently insert into that temp

spark stateful streaming with checkpoint + kafka producer

How can I integrate Kafka producer with spark stateful streaming which uses checkpoint along with StreamingContext.getOrCreate. I read this post: How to write s

Extract value from array in Spark

I am trying to extract a value from an array in SparkSQL, but getting the error below: Example column customer_details {"original_customer_id":"ch_382820","fi

Why my Akka main actor stops even though behavior doesn't change?

I have written a small application, but there is a problem that my app doesn't wait for my actors to stop, and stops them before their actions are completed. I