-
Notifications
You must be signed in to change notification settings - Fork 140
Java: Numeric Type Promotion #2224
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also document type promotion of functions
Co-authored-by: Matthias Schur <107557548+MattSchur@users.noreply.github.com>
agoerler
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to decide wether we use CDS type names Int32 or hana.Real or the constants of CdsBaseType. As we don't mention the CAP Java's CdsBaseType yet ion the documentation we could stick to the CDS type names.
Or we extend the table https://pages.github.tools.sap/cap/docs/java/cds-data#predefined-types and the table for the HANA types with a column for the CdsBaseType names.
Co-authored-by: Adrian Görler <adrian.goerler@sap.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a supportive code review enhanced by AI assistance. These insights offer suggestions and observations that may help guide your development process. Please consider them as recommendations rather than definitive requirements. Your expertise and judgment remain the most important factors in making decisions about your code. The AI analysis is simply here to provide additional perspective and support your work.
Model: claude-sonnet-4-20250514 | Prompt Tokens: 1463 | Completion Tokens: 384
| ### Numeric Type Determination { #type-determination } | ||
|
|
||
| To have a consistent behavior across different databases, the CAP Java runtime applies numeric type determination in arithmetic expressions and numeric standard functions according to the following rules. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a brief introductory sentence to provide context before diving into the rules. For example:
### Numeric Type Determination { #type-determination }
The CAP Java runtime ensures consistent behavior across different databases by applying numeric type determination rules in arithmetic expressions and numeric standard functions.| `cds.Double`, `hana.REAL`, `cds.Decimal`, `cds.Int64`, `cds.Int32`, `cds.Int16`, `cds.UInt8` | ||
|
|
||
| - For addition, subtraction, and multiplication, the result type is the one with highest precedence among the operands. | ||
| - For division: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a colon after "For division" to maintain consistency with the formatting of "For addition, subtraction, and multiplication" above:
- For division:
java/cds-data.md
Outdated
| - **ceiling(x)**, **floor(x)**, **round(x)**: Return the same type as the input `x`. | ||
| - **min(x)**, **max(x)**, **sum(x)**: Aggregate functions return the same type as the argument `x`. | ||
| - **average(x)**: Returns `cds.Decimal` for exact numeric types and `cds.Double` for approximate numeric types. | ||
| - **count(x)**, **countdistinct(x)**: return `cds.Int64`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capitalize "Return" to maintain consistency with the capitalization pattern used in other function descriptions:
- **count(x)**, **countdistinct(x)**: Return `cds.Int64`.
No description provided.