imbajin commented on code in PR #3209:
URL: https://github.com/apache/hugegraph/pull/3209#discussion_r4033046031


##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/DataType.java:
##########
@@ -43,7 +45,14 @@ public enum DataType implements SerialEnum {
     TEXT(8, "text", String.class),
     BLOB(9, "blob", Blob.class),
     DATE(10, "date", Date.class),
-    UUID(11, "uuid", UUID.class);
+    UUID(11, "uuid", UUID.class),
+    /*
+     * Arbitrary-precision decimal (java.math.BigDecimal). Stored exactly; not 
a
+     * "number" in the isNumber() sense because it has no fixed-width, sortable
+     * encoding, so it can't be a sort key, a range/secondary index field or an
+     * OLAP range property.
+     */
+    DECIMAL(12, "decimal", BigDecimal.class);

Review Comment:
   ‼️ Blocking: yes. `DECIMAL` is still accepted as a vertex primary key: 
`VertexLabelBuilder.checkPrimaryKeys()` only checks that the key belongs to 
`properties`, and this PR adds no type guard. Core primary-id generation then 
passes the normalized `BigDecimal` through 
`ConditionQuery.concatValues()`/`LongEncoding`; 
`NumericUtil.numberToSortableLong()` converts non-integral values through 
`double` and throws on large integral values. A local probe showed 
`1.000000000000000001` and `1.000000000000000002` map to the same sortable 
long, while the uint256 value advertised by this PR throws 
`ArithmeticException: Overflow`. The REST batch path also hashes the raw string 
before core normalization. Please reject DECIMAL primary keys or add a lossless 
canonical primary-key encoding, with tests for fractional precision and uint256 
values.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to