mc2-project / mc2-project/opaque-sql
Error deserializing float to string
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 190
- Forks
- 70
- PR merge metrics
- No merged PRs in 30d
Description
To demonstrate the error, I can simply follow the instructions from Using Opaque SQL in the documentation but substitute the given integers for floats:
scala> df.show()
+----+------+
|word| count|
+----+------+
| foo|508.41|
| bar|717.13|
| baz| 82.31|
+----+------+
scala> df.printSchema
root
|-- word: string (nullable = true)
|-- count: float (nullable = false)
If I encrypt the dataframe, then decrypt it I get the following:
scala> dfEncrypted.show()
+----+----------+
|word| count|
+----+----------+
| foo|508.410004|
| bar|717.130005|
| baz| 82.309998|
+----+----------+
scala> dfEncrypted.printSchema
root
|-- word: string (nullable = true)
|-- count: float (nullable = false)
scala> dfEncrypted.collect()
res18: Array[org.apache.spark.sql.Row] = Array([foo,508.41], [bar,717.13], [baz,82.31])
So it appears that there is an error in de-serializing the floats to a string as the displayed numbers are incorrect when using show() but not collect().
One thing I noticed when debugging is that, if I set breakpoints in the various cases here, running collect() shows that both the StringField and FloatField cases are entered (as expected), but running show() prints out that StringField is visited twice so it would seem that the float value is being turned into a string (incorrectly) somewhere in C++ code before Scala? But I am not sure.
Contributor guide
No contributing guide indexed for this repository
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
Reproduce the float case by following the documented “Using Opaque SQL” instructions and comparing show() with collect(). Start at the StringField and FloatField cases in src/main/scala/edu/berkeley/cs/rise/opaque/Utils.scala around line 722, then trace the path used by show() toward the C++ boundary. Done means float values display consistently without changing collect() results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala, spark
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100