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

Changed GenericLiteralVisitor to treat float literals as Double by default #3074

Merged
merged 2 commits into from
Mar 24, 2025

Conversation

andreachild
Copy link
Contributor

@andreachild andreachild commented Mar 14, 2025

Currently, when a floating-point number is provided without a suffix in Gremlin Lang (e.g., 1.0 or -123.456), it's automatically converted to a BigDecimal. This differs from most programming
languages where floating-point literals are typically treated as double-precision values.

To align the behavior of Gremlin Lang with common programming language conventions and user expectations, this changeset changes GremlinLangScriptEngine via GenericLiteralVisitor to treat float literals without explicit type suffixes (like 'm', 'f', or 'd') as Double by default. Users who need BigDecimal precision can still use the 'm' suffix (e.g., 1.0m). Gremlin Groovy will still default to BigDecimal for float literals.

@codecov-commenter
Copy link

codecov-commenter commented Mar 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (3.8-dev@8c6f908). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             3.8-dev    #3074   +/-   ##
==========================================
  Coverage           ?   76.36%           
  Complexity         ?    13236           
==========================================
  Files              ?     1062           
  Lines              ?    61577           
  Branches           ?     7347           
==========================================
  Hits               ?    47022           
  Misses             ?    12035           
  Partials           ?     2520           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@andreachild andreachild force-pushed the 3.8-doubleAsDefault branch from c3f33b0 to 315195c Compare March 17, 2025 18:35
@andreachild andreachild marked this pull request as ready for review March 17, 2025 19:10
@xiazcy
Copy link
Contributor

xiazcy commented Mar 17, 2025

VOTE +1

@andreachild andreachild force-pushed the 3.8-doubleAsDefault branch from aea2fa9 to b01d3b3 Compare March 18, 2025 00:11
@Cole-Greer
Copy link
Contributor

VOTE +1

@kenhuuu
Copy link
Contributor

kenhuuu commented Mar 18, 2025

VOTE +1

…in Gremlin Lang (e.g., 1.0 or -123.456), it's automatically converted to a BigDecimal. This differs from most programming

languages where floating-point literals are typically treated as double-precision values.

To align the behavior of Gremlin Lang with common programming language conventions and user expectations, this changeset changes GremlinLangScriptEngine via GenericLiteralVisitor to treat float literals without explicit type suffixes (like 'm', 'f', or 'd') as Double by default. Users who need BigDecimal precision can still use the 'm' suffix (e.g., 1.0m).
@andreachild andreachild force-pushed the 3.8-doubleAsDefault branch from 1944e3e to 179f8d6 Compare March 18, 2025 20:33
@Cole-Greer Cole-Greer merged commit f645645 into apache:3.8-dev Mar 24, 2025
1 check 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.

5 participants