Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VL] Fix timestamp precision loss in serializer #5376

Merged
merged 4 commits into from
Apr 15, 2024

Conversation

zhli1142015
Copy link
Contributor

@zhli1142015 zhli1142015 commented Apr 12, 2024

What changes were proposed in this pull request?

By default PrestoVectorSerde use millisecond precision for timestamp data. We observed timestamp prescision loseing when doing broadcast serialization. We need to fix this by setting useLosslessTimestamp for PrestoVectorSerde.

import org.apache.spark.sql.functions.expr
import org.apache.spark.sql.catalyst.expressions._
spark.range(0, 5).toDF("id").createOrReplaceTempView("target")
spark.range(0, 10)
        .toDF("id")
        .withColumn("timestampOne", expr("timestamp_micros(id)"))
        .createOrReplaceTempView("source")

spark.sql("SELECT unix_micros(source.timestampOne) FROM source RIGHT OUTER JOIN target ON target.id = source.id").show(false)

Wrong result:

+-------------------------+
|unix_micros(timestampOne)|
+-------------------------+
|0                        |
|0                        |
|0                        |
|0                        |
|0                        |
+-------------------------+

Expected result:

+-------------------------+
|unix_micros(timestampOne)|
+-------------------------+
|0                        |
|1                        |
|2                        |
|3                        |
|4                        |
+-------------------------+

How was this patch tested?

UT

Copy link

Thanks for opening a pull request!

Could you open an issue for this pull request on Github Issues?

https://github.com/apache/incubator-gluten/issues

Then could you also rename commit message and pull request title in the following format?

[GLUTEN-${ISSUES_ID}][COMPONENT]feat/fix: ${detailed message}

See also:

@zhli1142015 zhli1142015 changed the title [VL] Fix timestamp precision in broadcast serializer [VL] Fix timestamp precision loss in broadcast serializer Apr 12, 2024
@zhli1142015 zhli1142015 changed the title [VL] Fix timestamp precision loss in broadcast serializer [VL] Fix timestamp precision loss in serializer Apr 12, 2024
@zhli1142015
Copy link
Contributor Author

cc @PHILO-HE and @marin-ma , thanks.

@zhli1142015
Copy link
Contributor Author

BTW, from this setting's comments, it's used for spilling also, not sure if this should be set to true for spilling also?
https://github.com/facebookincubator/velox/blob/main/velox/serializers/PrestoSerializer.h#L62

@marin-ma
Copy link
Contributor

Copy link
Contributor

@PHILO-HE PHILO-HE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! cc @zhztheplayer

@zhli1142015 zhli1142015 merged commit 6460158 into apache:main Apr 15, 2024
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants