Supported Literals
Comparing Values With java.util.Date
Geode supports the following literal types:
You can compare temporal literal values DATE
, TIME
, and TIMESTAMP
with java.util.Date
values. There is no literal for java.util.Date
in the query language.
Type Conversion
The Geode query processor performs implicit type conversions and promotions under certain cases in order to evaluate expressions that contain different types. The query processor performs binary numeric promotion, method invocation conversion, and temporal type conversion.
Binary Numeric Promotion
The query processor performs binary numeric promotion on the operands of the following operators:
- Comparison operators <, <=, >, and >=
- Equality operators = and <>
- Binary numeric promotion widens the operands in a numeric expression to the widest representation used by any of the operands. In each expression, the query processor applies the following rules in the prescribed order until a conversion is made:
- If either operand is of type double, the other is converted to double
- If either operand is of type float, the other is converted to float
- If either operand is of type long, the other is converted to long
- Both operands are converted to type int char
Method Invocation Conversion
Method invocation conversion in the query language follows the same rules as Java method invocation conversion, except that the query language uses runtime types instead of compile time types, and handles null arguments differently than in Java. One aspect of using runtime types is that an argument with a null value has no typing information, and so can be matched with any type parameter. When a null argument is used, if the query processor cannot determine the proper method to invoke based on the non-null arguments, it throws an AmbiguousNameException
Temporal Type Conversion
The temporal types that the query language supports include the Java types java.util.Date , java.sql.Date , java.sql.Time , and java.sql.Timestamp , which are all treated the same and can be compared and used in indexes. When compared with each other, these types are all treated as nanosecond quantities.
Enum Conversion
Enums are not automatically converted. To use Enum values in query, you must use the toString method of the enum object or use a query bind parameter. See Enum Objects for more information.
Query Evaulation of Float.NaN and Double.NaN
Float.NaN and Double.NaN are not evaluated as primitives; instead, they are compared in the same manner used as the JDK methods Float.compareTo and Double.compareTo. See Double.NaN and Float.NaN Comparisons for more information.