Skip to content

Fix round double for postgres#5368

Merged
georgesittas merged 5 commits intotobymao:mainfrom
blecourt-private:fix-round-double-for-postgres
Jul 7, 2025
Merged

Fix round double for postgres#5368
georgesittas merged 5 commits intotobymao:mainfrom
blecourt-private:fix-round-double-for-postgres

Conversation

@blecourt-private
Copy link
Contributor

Fixing #5366

@blecourt-private blecourt-private marked this pull request as draft July 7, 2025 14:35
@blecourt-private
Copy link
Contributor Author

Hi @georgesittas

I'm not sure what I should add here to make this pull request complete.

One thing I'm in doubt about is how much effort should be put into verifying with various dialects? For instance I have checked various queries directly in a Postgres and a RisingWave engine (making sure that round(double precision, integer) doesn't work and that the proposed changes are needed to transpile correctly) but I haven't done the same in Redshift and Materialize, instead relying on their official docs.

Copy link
Collaborator

@georgesittas georgesittas left a comment

Choose a reason for hiding this comment

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

One thing I'm in doubt about is how much effort should be put into verifying with various dialects? For instance I have checked various queries directly in a Postgres and a RisingWave engine (making sure that round(double precision, integer) doesn't work and that the proposed changes are needed to transpile correctly) but I haven't done the same in Redshift and Materialize, instead relying on their official docs.

That's fine, the testing you described suffices for this use case.

FYI, this is a breaking change, since it changes the AST's structure. Otherwise, the PR looks good, I don't expect any issues from preemptively casting the argument for postgres if we can't infer it.

exp.Rand: rename_func("RANDOM"),
exp.RegexpLike: lambda self, e: self.binary(e, "~"),
exp.RegexpILike: lambda self, e: self.binary(e, "~*"),
exp.Round: _round,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Can we get rid of this entry and move _round under the Generator class, named as round_sql? I'd also inline _to_decimal.

@georgesittas georgesittas linked an issue Jul 7, 2025 that may be closed by this pull request
@georgesittas georgesittas marked this pull request as ready for review July 7, 2025 18:21
@georgesittas
Copy link
Collaborator

I'll get this in and take it to the finish line. Thanks!

@georgesittas georgesittas merged commit a3227de into tobymao:main Jul 7, 2025
1 of 7 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.

Round of double not transpiled correctly for postgres

2 participants