typelevel / typelevel/frameless
Columns of same type mixed up during grouping, select and as
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 895
- Forks
- 135
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 3
Description
I took a TypedDataset of case class A, grouped it, mixing the order of two columns of the same type, resulting in a tupled dataset. I had to do this way, don't ask. To get stuff right again, I selected the columns in the right order again, and finally used .as[A] again to get me back a nice TypedDataset of my type A.
Expected Behaviour: Everything just as it has been, right columns ending up in the right place.
Actual behaviour: The mixed up columns weren't put in the right order by the select I issued at the end.
I suspect the quirk is somewhere within .as[A] but i cannot pinpoint it tbh.
Here a small reproducer:
import frameless._
import frameless.syntax._
import frameless.functions.aggregate.{first, min}
// create spark session ...
implicit val sparkSession: SparkSession = session
case class ConfusingColumns(name: String, company: String, created: Long)
val data = ConfusingColumns("Joe", "snakeoil Inc.", 123L) ::
ConfusingColumns("Barb", "ACME", 42L) ::
ConfusingColumns("Joe", "snakeoil Inc.", 0L) :: Nil
val ds: TypedDataset[ConfusingColumns] = TypedDataset.create(data)
val grouped = ds
.groupBy(
ds('company)
)
.agg(
first(ds('name)),
min(ds('created))
)
val confused = grouped
.select(
grouped('_2),
grouped('_1),
grouped('_3)
)
.as[ConfusingColumns]
confused.dataset.show()
Output (compare the case classes in data above):
+-------------+-------+-------+
| name|company|created|
+-------------+-------+-------+
|snakeoil Inc.| Joe| 0|
| ACME| Barb| 42|
+-------------+-------+-------+
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied Scala reproducer and run the grouped, reordered select, and .as[ConfusingColumns] sequence to confirm the column mix-up. Trace the .as[A] conversion and the grouped select entry points to determine where same-typed columns lose their intended order. Done means the resulting ConfusingColumns fields match the original column selections and the reproducer output is corrected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala, spark
- Domain
- data-engineering
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100