112,834 questions
1
vote
1
answer
68
views
Regular expression not catching case labels in file
I am working out of Scala For The Impatient (3rd Edition) in my spare time. (I am not taking a class.). I am processing a list of java files with Scala. Specifically, I am looking for case labels, ...
-1
votes
0
answers
72
views
How to write Monad for class MyPair[+A, +B]
I have no idea how to implement MonadError for case class MyPair[+A, +B](a: A, b: B), since I don't understand how to deal with 2 types in Monad.
I've been trying to write it for 2 weeks already, no ...
1
vote
2
answers
81
views
Using PPrint, can I exclude the named argument from Some ("value"), but not those of other case classes?
I am currently using the PPrint library to generate case classes to paste into my regression test Scala code, based on the values my existing code returns:
case class MyCaseClass(
byte: Option[...
2
votes
1
answer
63
views
backslash count in raw string interpolation in scala
I am using Scala 3.3.7.
When I do
val str1 = raw"\\\" // compile error: unclosed string literal
It is considering the \" as a single character.
But when I do
val str1 = raw"\\\\&...
Tooling
0
votes
1
replies
40
views
Create a integrated test with ZIO and Quill
Hello I'm trying to create a integrated database test using testcontainer, my testcotainer is running with liquibase, my problem is about create quill connection, follow my code:
container config:
...
1
vote
0
answers
72
views
trying to read bigquery array colum and passing it as columns to fetch from spark dataframe
I have a bigquery table with array column named as "column_list "
ALTER TABLE `test-project.TEST_DATASET.TEST_TABLE`
ADD COLUMN column_list ARRAY<STRING>;
update `test-project....
0
votes
1
answer
93
views
col function error type mismatch: found string required Int
I am attempting to programmatically remove specific columns/fields from a dataframe (anything that starts with _), whether the field is in the root or in a struct, using the dropFields method.
For ...
1
vote
0
answers
93
views
Lucene Boolean Operator Problems
Using Lucene, certain queries parse and execute in a completely unexpected way.
Here's the code for testing it (written in Scala, but can be easily translated to Java too):
import org.apache.lucene....
0
votes
1
answer
76
views
How to reference a CSV column with parentheses and a decimal point in Spark SQL or COALESCE expression?
I’m working on a data ingestion pipeline using Apache Spark (triggered via a Cloud Function on Dataproc).
The input CSV contains column names that include special characters such as parentheses and a ...
1
vote
0
answers
75
views
How to run sbt offline (downloading all the dependecies and moving)
I wanted to use riscv-torture project to create tests in a server that has no access to the internet. I firstly run it in my ubuntu 22.04 then copy .sbt .ivy2 .cache/coursier .cache/JPN folders to the ...
2
votes
1
answer
120
views
Determine the variance of a class/type parameter by reflection without using `TypeTag`
I can get the formal type parameters (type variables) of any Java class/interface, including those defined in Scala, through java.lang.reflect API.
In addition, Scala allows to define type parameters ...
-1
votes
2
answers
138
views
When to use conditionals vs pattern matching, is there a performance trade off? [closed]
I have two possibilities to implement a simple list drop method.
A:
def drop[A](l: List[A], n: Int): List[A] = (n, l) match
case (n, l) if n <= 0 => l
case (_, Cons(_, t)) => drop(t, n - ...
1
vote
0
answers
86
views
scala-maven-plugin cannot compile Java15+ feature text block
mixed compilation project of Scala and Java, and now upgrade jdk8->jdk21, use Java15+ feature text block
before:
String sql = "update hinsight.homeco_user_task set \n" +
"...
0
votes
0
answers
82
views
Json matcher stop matching after migration to specs2 4.22
I have a small specification that uses json matcher
import org.specs2.matcher.JsonMatchers
import org.specs2.mutable.Specification
class Test extends Specification with JsonMatchers {
"test&...
1
vote
0
answers
47
views
Get list of settings from another setting in SBT
I'm new to Scala and I'm having trouble wrapping my head around the following scenario - I want to have a centralized spot in build.sbt where we log the current profile and set certain values based on ...