Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 20:17
    krisweiss opened #2211
  • 15:33

    julienrf on main

    Fix links to IntelliJ and SBT … Remove the IntelliJ and SBT ent… Merge pull request #1286 from s… (compare)

  • 15:33
    julienrf closed #1286
  • 15:33
    julienrf closed #1285
  • 15:33
    julienrf commented #1286
  • 15:32
    s5bug synchronize #1286
  • 13:16
    SethTisue labeled #2210
  • 13:16
    SethTisue commented #2210
  • 11:49
    krisweiss edited #2210
  • 11:48
    krisweiss opened #2210
  • 10:59
    julienrf commented #1286
  • 08:57
    s5bug commented #1286
  • 08:10
    julienrf commented #1286
  • 07:49
    s5bug commented #1286
  • 07:48
    s5bug opened #1286
  • 07:45
    julienrf commented #1285
  • 07:40
    julienrf commented #2205
  • 07:40
    julienrf commented #2205
  • 07:39
    s5bug commented #1285
  • 07:38
    julienrf commented #1285
Rob Norris
@tpolecat
What does it say?
idk-kid
@idk-kid
@BalmungSan it still complains
Luis Miguel Mejía Suárez
@BalmungSan
Really? What is the error this time?
Rob Norris
@tpolecat
Are you sure org.apache.spark.sql.catalyst.plans.logical is a type? The capitalization is suspicious.
Dan Sokolsky
@dansok
intellij doesn't recognize logical. highlights it in red, and gives you one of three opotionns along the lie of "create case class logical"
although the import statement import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan does in fact import LogicalPlan
Rob Norris
@tpolecat
Are you sure you don't want case logicalPlan: LogicalPlan => ...?
Dan Sokolsky
@dansok
I am
Rob Norris
@tpolecat
Why don't you want that?
Dan Sokolsky
@dansok
I want to filter all logical statements and make sure they are all SELECTs
(of type org.apache.spark.sql.catalyst.plans.logical.Project)
Rob Norris
@tpolecat
Ok then case logicalPlan: Project => ...
And your return type can be Seq[Project]
idk-kid
@idk-kid
@BalmungSan it's the same complaint
Dan Sokolsky
@dansok
but I want to throw if there is, say, an insert
so I want to get all logical statements, not just the selects
so I need to filter for org.apache.spark.sql.catalyst.plans.logical.*, not Project
Rob Norris
@tpolecat
Oh I see. You want to filter for anything in that package?
You can't do that.
You would need to check for each type, or for their common supertype if they have one.
Dan Sokolsky
@dansok
alright plan b -- convert to JSON and parse strings 🤘
yolo
"class" : "org.apache.spark.sql.catalyst.plans.logical.InsertIntoStatement"
I was trying to be a good citizen
Luis Miguel Mejía Suárez
@BalmungSan
I am sure my attempt to reproduce the code has many differences, try playing with the code until you get the same error.
Another possibility is that maybe the error you are seeing is not real? Like it is just an IDE thing but a real compiler will not produce it?
Dan Sokolsky
@dansok
how to get only the match from a regex?
I'm getting a hit, but it's returning the entire line

so,

val regex: Regex = "\"class\":\"org.apache.spark.sql.catalyst.plans.logical.*\"".r
println(regex.findAllMatchIn(queryString).toList)

gives back

List("class":"org.apache.spark.sql.catalyst.plans.logical.InsertIntoStatement","num-children":1,"table":[{"class":"org.apache.spark.sql.catalyst.analysis.UnresolvedRelation","num-children":0,"multipartIdentifier":"[table_1]"}],"partitionSpec":null,"query":0,"overwrite":false,"ifPartitionNotExists":false},{"class":"org.apache.spark.sql.catalyst.analysis.UnresolvedInlineTable","num-children":0,"names":"[col1]","rows")

where I am only looking for

"class":"org.apache.spark.sql.catalyst.plans.logical.InsertIntoStatement"

to be returned

Derek Wickern
@dwickern
For my Play plugin to work with any Play version [2.8.0,2.9), should the plugin depend on 2.8.0? Or should it depend on the range like [2.8.0,2.9.0[ or 2.8.+? Does it matter?
Martijn
@martijnhoekstra:matrix.org
[m]
@dansok: values in scala have types. findAllMatchIn returns a value of the type Iterator[Match]. You can then use those matches to get what you want. But it's not clear to me what it is you want exactly. Is it the matched text? Then you can use findAllIn which returns the matched strings rather than match objects
or select the matched member on the match object, which will give you the matched text
@dwickern: you can just depend on 2.8.0, and everything should work as expected.
you can also do the range, or at least, I've read that before, but I've never seen anyone do that in the wild
Derek Wickern
@dwickern
yeah, I haven't seen anyone use version ranges either
som-snytt
@som-snytt

@dansok your regex is greedy

scala> val r = raw"""(".*")""".r
val r: scala.util.matching.Regex = (".*")

scala> r.findFirstIn(""""one" and "two"""")
val res0: Option[String] = Some("one" and "two")

scala> val r = raw"""("[^"]*")""".r
val r: scala.util.matching.Regex = ("[^"]*")

scala> r.findFirstIn(""""one" and "two"""")
val res1: Option[String] = Some("one")

Nobody can tell but dotty is my default snippet repl now. Also, I notice using raw for regex spells raw.r.

BalmungSan @BalmungSan starts to sweat for resisting the urge of doing the "rawr" meme reference because is too cringe.
Rob Norris
@tpolecat
https://regexper.com is useful when you're trying to see what a regex does
som-snytt
@som-snytt
I have wanted string.r.explain for an instrumented regex that tells me what it did and why.
Rob Norris
@tpolecat
It could give you a URL to rexper populated with the regex. I wish regexper provided a way to quote your regex because that ends up being a big source of bugs.
gitleet
@gitleet
When reading a inline function (anonymous lambda?), do you read right from left or left to right? f: (String, T) => String = (a: String, b: T) => b.toString
Rob Norris
@tpolecat
What do you mean?
gitleet
@gitleet
I have trouble reading that ....
function that takes 2 params, string and T, and returns a String?
Rob Norris
@tpolecat
Yeah I would say something like "String T to String"
The parameter types are inferred on the RHS so you can say ... = (a, b) => b.toString which shortens it a bit.
gitleet
@gitleet
how can I add this inline function to a value? val f = .... ?