You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2015/08/01 00:43:19 UTC
[42/50] [abbrv] incubator-calcite git commit: [CALCITE-735]
Primitive.DOUBLE.min should be large and negative
[CALCITE-735] Primitive.DOUBLE.min should be large and negative
Project: http://git-wip-us.apache.org/repos/asf/incubator-calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/b812e045
Tree: http://git-wip-us.apache.org/repos/asf/incubator-calcite/tree/b812e045
Diff: http://git-wip-us.apache.org/repos/asf/incubator-calcite/diff/b812e045
Branch: refs/heads/branch-release
Commit: b812e045088e7eec83005fd04a4c64cd1adc71b7
Parents: bf42376
Author: Julian Hyde <jh...@apache.org>
Authored: Sun May 17 21:09:49 2015 -0700
Committer: Julian Hyde <jh...@apache.org>
Committed: Sun May 17 21:09:49 2015 -0700
----------------------------------------------------------------------
core/src/test/resources/sql/agg.oq | 35 ++++++++++++++
.../apache/calcite/linq4j/tree/Primitive.java | 51 ++++++++++++++------
2 files changed, 70 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/b812e045/core/src/test/resources/sql/agg.oq
----------------------------------------------------------------------
diff --git a/core/src/test/resources/sql/agg.oq b/core/src/test/resources/sql/agg.oq
index 0cb2dba..0936b0e 100644
--- a/core/src/test/resources/sql/agg.oq
+++ b/core/src/test/resources/sql/agg.oq
@@ -555,6 +555,41 @@ from emp group by cube(deptno, gender);
!use scott
+# [KYLIN-751] Max on negative double values is not working
+# [CALCITE-735] Primitive.DOUBLE.min should be large and negative
+select max(v) as x, min(v) as n
+from (values cast(-86.4 as double), cast(-100 as double)) as t(v);
++-------+--------+
+| X | N |
++-------+--------+
+| -86.4 | -100.0 |
++-------+--------+
+(1 row)
+
+!ok
+
+select max(v) as x, min(v) as n
+from (values cast(-86.4 as double), cast(-100 as double), cast(2 as double)) as t(v);
++-----+--------+
+| X | N |
++-----+--------+
+| 2.0 | -100.0 |
++-----+--------+
+(1 row)
+
+!ok
+
+select max(v) as x, min(v) as n
+from (values cast(-86.4 as float), cast(-100 as float)) as t(v);
++-------+--------+
+| X | N |
++-------+--------+
+| -86.4 | -100.0 |
++-------+--------+
+(1 row)
+
+!ok
+
# Aggregate FILTER
select deptno,
sum(sal) filter (where job = 'CLERK') c_sal,
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/b812e045/linq4j/src/main/java/org/apache/calcite/linq4j/tree/Primitive.java
----------------------------------------------------------------------
diff --git a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/Primitive.java b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/Primitive.java
index 67648dd..f2e42d3 100644
--- a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/Primitive.java
+++ b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/Primitive.java
@@ -36,18 +36,23 @@ import java.util.Map;
* (e.g. {@link Integer}).</p>
*/
public enum Primitive {
- BOOLEAN(Boolean.TYPE, Boolean.class, 1, false, false, true),
- BYTE(Byte.TYPE, Byte.class, 2, (byte) 0, Byte.MIN_VALUE, Byte.MAX_VALUE),
+ BOOLEAN(Boolean.TYPE, Boolean.class, 1, false, false, null, null, true, -1),
+ BYTE(Byte.TYPE, Byte.class, 2, (byte) 0, Byte.MIN_VALUE, null, null,
+ Byte.MAX_VALUE, Byte.SIZE),
CHAR(Character.TYPE, Character.class, 2, (char) 0, Character.MIN_VALUE,
- Character.MAX_VALUE),
- SHORT(Short.TYPE, Short.class, 2, (short) 0, Short.MIN_VALUE,
- Short.MAX_VALUE),
- INT(Integer.TYPE, Integer.class, 2, 0, Integer.MIN_VALUE, Integer.MAX_VALUE),
- LONG(Long.TYPE, Long.class, 2, 0L, Long.MIN_VALUE, Long.MAX_VALUE),
- FLOAT(Float.TYPE, Float.class, 3, 0F, Float.MIN_VALUE, Float.MAX_VALUE),
- DOUBLE(Double.TYPE, Double.class, 3, 0D, Double.MIN_VALUE, Double.MAX_VALUE),
- VOID(Void.TYPE, Void.class, 4, null, null, null),
- OTHER(null, null, 5, null, null, null);
+ null, null, Character.MAX_VALUE, Character.SIZE),
+ SHORT(Short.TYPE, Short.class, 2, (short) 0, Short.MIN_VALUE, null, null,
+ Short.MAX_VALUE, Short.SIZE),
+ INT(Integer.TYPE, Integer.class, 2, 0, Integer.MIN_VALUE, null, null,
+ Integer.MAX_VALUE, Integer.SIZE),
+ LONG(Long.TYPE, Long.class, 2, 0L, Long.MIN_VALUE, null, null,
+ Long.MAX_VALUE, Long.SIZE),
+ FLOAT(Float.TYPE, Float.class, 3, 0F, -Float.MAX_VALUE, -Float.MIN_VALUE,
+ Float.MIN_VALUE, Float.MAX_VALUE, Float.SIZE),
+ DOUBLE(Double.TYPE, Double.class, 3, 0D, -Double.MAX_VALUE, -Double.MIN_VALUE,
+ Double.MIN_VALUE, Double.MAX_VALUE, Double.SIZE),
+ VOID(Void.TYPE, Void.class, 4, null, null, null, null, null, -1),
+ OTHER(null, null, 5, null, null, null, null, null, -1);
public final Class primitiveClass;
public final Class boxClass;
@@ -62,13 +67,23 @@ public enum Primitive {
/** The minimum value of this primitive class. */
public final Object min;
+ /** The largest value that is less than zero. Null if not applicable for this
+ * type. */
+ public final Object maxNegative;
+
+ /** The smallest value that is greater than zero. Null if not applicable for
+ * this type. */
+ public final Object minPositive;
+
/** The maximum value of this primitive class. */
public final Object max;
- private static final Map<Class, Primitive> PRIMITIVE_MAP =
- new HashMap<Class, Primitive>();
- private static final Map<Class, Primitive> BOX_MAP =
- new HashMap<Class, Primitive>();
+ /** The size of a value of this type, in bits. Null if not applicable for this
+ * type. */
+ public final int size;
+
+ private static final Map<Class, Primitive> PRIMITIVE_MAP = new HashMap<>();
+ private static final Map<Class, Primitive> BOX_MAP = new HashMap<>();
static {
Primitive[] values = Primitive.values();
@@ -83,7 +98,8 @@ public enum Primitive {
}
Primitive(Class primitiveClass, Class boxClass, int family,
- Object defaultValue, Object min, Object max) {
+ Object defaultValue, Object min, Object maxNegative, Object minPositive,
+ Object max, int size) {
this.primitiveClass = primitiveClass;
this.family = family;
this.primitiveName =
@@ -91,7 +107,10 @@ public enum Primitive {
this.boxClass = boxClass;
this.defaultValue = defaultValue;
this.min = min;
+ this.maxNegative = maxNegative;
+ this.minPositive = minPositive;
this.max = max;
+ this.size = size;
}
/**