[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-23 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15346117#comment-15346117
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

Github user asfgit closed the pull request at:

https://github.com/apache/flink/pull/2088


> Add BigDecimal/BigInteger support to Table API
> --
>
> Key: FLINK-3859
> URL: https://issues.apache.org/jira/browse/FLINK-3859
> Project: Flink
>  Issue Type: New Feature
>  Components: Table API & SQL
>Reporter: Timo Walther
>Assignee: Timo Walther
>Priority: Critical
>
> Since FLINK-3786 has been solved, we can now start integrating 
> BigDecimal/BigInteger into the Table API.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-23 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15346099#comment-15346099
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

Github user twalthr commented on the issue:

https://github.com/apache/flink/pull/2088
  
Thanks Fabian. Merging...


> Add BigDecimal/BigInteger support to Table API
> --
>
> Key: FLINK-3859
> URL: https://issues.apache.org/jira/browse/FLINK-3859
> Project: Flink
>  Issue Type: New Feature
>  Components: Table API & SQL
>Reporter: Timo Walther
>Assignee: Timo Walther
>Priority: Critical
>
> Since FLINK-3786 has been solved, we can now start integrating 
> BigDecimal/BigInteger into the Table API.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-23 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15346062#comment-15346062
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

Github user fhueske commented on the issue:

https://github.com/apache/flink/pull/2088
  
Thanks for refactoring the tests @twalthr! LGTM


> Add BigDecimal/BigInteger support to Table API
> --
>
> Key: FLINK-3859
> URL: https://issues.apache.org/jira/browse/FLINK-3859
> Project: Flink
>  Issue Type: New Feature
>  Components: Table API & SQL
>Reporter: Timo Walther
>Assignee: Timo Walther
>Priority: Critical
>
> Since FLINK-3786 has been solved, we can now start integrating 
> BigDecimal/BigInteger into the Table API.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-23 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15345954#comment-15345954
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

Github user twalthr commented on the issue:

https://github.com/apache/flink/pull/2088
  
If there are no objections, I would merge this later today...


> Add BigDecimal/BigInteger support to Table API
> --
>
> Key: FLINK-3859
> URL: https://issues.apache.org/jira/browse/FLINK-3859
> Project: Flink
>  Issue Type: New Feature
>  Components: Table API & SQL
>Reporter: Timo Walther
>Assignee: Timo Walther
>Priority: Critical
>
> Since FLINK-3786 has been solved, we can now start integrating 
> BigDecimal/BigInteger into the Table API.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-21 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15342053#comment-15342053
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

Github user twalthr commented on the issue:

https://github.com/apache/flink/pull/2088
  
@fhueske I have changed the `ExpressionTestBase`. Now one unit tests only 
needs one compilation step. The runtime is still not perfect but could be 
reduced by about 75 % (at least on my PC).


> Add BigDecimal/BigInteger support to Table API
> --
>
> Key: FLINK-3859
> URL: https://issues.apache.org/jira/browse/FLINK-3859
> Project: Flink
>  Issue Type: New Feature
>  Components: Table API & SQL
>Reporter: Timo Walther
>Assignee: Timo Walther
>Priority: Critical
>
> Since FLINK-3786 has been solved, we can now start integrating 
> BigDecimal/BigInteger into the Table API.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15338502#comment-15338502
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

Github user twalthr commented on the issue:

https://github.com/apache/flink/pull/2088
  
I also already recognized the problem of long running tests. I think will 
rework the test base again. So that there is one compilation per unit test.


> Add BigDecimal/BigInteger support to Table API
> --
>
> Key: FLINK-3859
> URL: https://issues.apache.org/jira/browse/FLINK-3859
> Project: Flink
>  Issue Type: New Feature
>  Components: Table API & SQL
>Reporter: Timo Walther
>Assignee: Timo Walther
>Priority: Critical
>
> Since FLINK-3786 has been solved, we can now start integrating 
> BigDecimal/BigInteger into the Table API.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-18 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15338204#comment-15338204
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

Github user fhueske commented on the issue:

https://github.com/apache/flink/pull/2088
  
Won't merge this PR at this point. A few Travis builds timed out and I 
found that the added expression tests increase build time by about one minute 
due to the code-gen compilation overhead. 

@twalthr, do you think we can adapt the tests to batch several expressions 
into a single class with multiple methods to invoke the compiler less 
frequently?


> Add BigDecimal/BigInteger support to Table API
> --
>
> Key: FLINK-3859
> URL: https://issues.apache.org/jira/browse/FLINK-3859
> Project: Flink
>  Issue Type: New Feature
>  Components: Table API & SQL
>Reporter: Timo Walther
>Assignee: Timo Walther
>Priority: Critical
>
> Since FLINK-3786 has been solved, we can now start integrating 
> BigDecimal/BigInteger into the Table API.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-17 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15335927#comment-15335927
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

Github user fhueske commented on the issue:

https://github.com/apache/flink/pull/2088
  
Merging


> Add BigDecimal/BigInteger support to Table API
> --
>
> Key: FLINK-3859
> URL: https://issues.apache.org/jira/browse/FLINK-3859
> Project: Flink
>  Issue Type: New Feature
>  Components: Table API & SQL
>Reporter: Timo Walther
>Assignee: Timo Walther
>Priority: Critical
>
> Since FLINK-3786 has been solved, we can now start integrating 
> BigDecimal/BigInteger into the Table API.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-15 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15331785#comment-15331785
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

Github user fhueske commented on the issue:

https://github.com/apache/flink/pull/2088
  
Thanks for the update @twalthr. The changes look good. Should be good to 
merge after the aggregators commit is added.


> Add BigDecimal/BigInteger support to Table API
> --
>
> Key: FLINK-3859
> URL: https://issues.apache.org/jira/browse/FLINK-3859
> Project: Flink
>  Issue Type: New Feature
>  Components: Table API
>Reporter: Timo Walther
>Assignee: Timo Walther
>Priority: Critical
>
> Since FLINK-3786 has been solved, we can now start integrating 
> BigDecimal/BigInteger into the Table API.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-15 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15331751#comment-15331751
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

Github user fhueske commented on a diff in the pull request:

https://github.com/apache/flink/pull/2088#discussion_r67161013
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/codegen/calls/ScalarFunctions.scala
 ---
@@ -143,15 +143,30 @@ object ScalarFunctions {
 new MultiTypeMethodCallGen(BuiltInMethods.ABS))
 
   addSqlFunction(
+ABS,
+Seq(BIG_DEC_TYPE_INFO),
+new MultiTypeMethodCallGen(BuiltInMethods.ABS_DEC))
+
+  addSqlFunction(
--- End diff --

I see, thanks


> Add BigDecimal/BigInteger support to Table API
> --
>
> Key: FLINK-3859
> URL: https://issues.apache.org/jira/browse/FLINK-3859
> Project: Flink
>  Issue Type: New Feature
>  Components: Table API
>Reporter: Timo Walther
>Assignee: Timo Walther
>Priority: Critical
>
> Since FLINK-3786 has been solved, we can now start integrating 
> BigDecimal/BigInteger into the Table API.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-15 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15331552#comment-15331552
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

Github user twalthr commented on the issue:

https://github.com/apache/flink/pull/2088
  
@fhueske I have updated my PR. Now comparisons should work. Once the build 
succeeded, I will add your commits.


> Add BigDecimal/BigInteger support to Table API
> --
>
> Key: FLINK-3859
> URL: https://issues.apache.org/jira/browse/FLINK-3859
> Project: Flink
>  Issue Type: New Feature
>  Components: Table API
>Reporter: Timo Walther
>Assignee: Timo Walther
>Priority: Critical
>
> Since FLINK-3786 has been solved, we can now start integrating 
> BigDecimal/BigInteger into the Table API.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-14 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15329421#comment-15329421
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

Github user fhueske commented on the issue:

https://github.com/apache/flink/pull/2088
  
Hi @twalthr, I implemented the aggregation functions and pushed the commit 
to a branch in my repository: https://github.com/fhueske/flink/tree/tableDecimal
I tried to open a PR against your repository, but Github didn't offer it as 
an option. :-(


> Add BigDecimal/BigInteger support to Table API
> --
>
> Key: FLINK-3859
> URL: https://issues.apache.org/jira/browse/FLINK-3859
> Project: Flink
>  Issue Type: New Feature
>  Components: Table API
>Reporter: Timo Walther
>Assignee: Timo Walther
>Priority: Critical
>
> Since FLINK-3786 has been solved, we can now start integrating 
> BigDecimal/BigInteger into the Table API.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15327635#comment-15327635
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

Github user twalthr commented on the issue:

https://github.com/apache/flink/pull/2088
  
@fhueske Thanks for reviewing my code. I totally forgot to test the 
comparisions. I will fix the issues and see what I can do for fixed precision / 
scale cases. Would be great if you could implement the corresponding 
aggregation functions.


> Add BigDecimal/BigInteger support to Table API
> --
>
> Key: FLINK-3859
> URL: https://issues.apache.org/jira/browse/FLINK-3859
> Project: Flink
>  Issue Type: New Feature
>  Components: Table API
>Reporter: Timo Walther
>Assignee: Timo Walther
>Priority: Critical
>
> Since FLINK-3786 has been solved, we can now start integrating 
> BigDecimal/BigInteger into the Table API.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15327625#comment-15327625
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

Github user twalthr commented on a diff in the pull request:

https://github.com/apache/flink/pull/2088#discussion_r66814270
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/codegen/calls/ScalarFunctions.scala
 ---
@@ -143,15 +143,30 @@ object ScalarFunctions {
 new MultiTypeMethodCallGen(BuiltInMethods.ABS))
 
   addSqlFunction(
+ABS,
+Seq(BIG_DEC_TYPE_INFO),
+new MultiTypeMethodCallGen(BuiltInMethods.ABS_DEC))
+
+  addSqlFunction(
--- End diff --

`FLOAT`, `INT` etc. is supported implicitly as they `shouldAutocastTo` 
`DOUBLE`. The most suitable method is later chosen by the Java compiler. 
Calcite's `SqlFunctions` provides methods for all basic types.


> Add BigDecimal/BigInteger support to Table API
> --
>
> Key: FLINK-3859
> URL: https://issues.apache.org/jira/browse/FLINK-3859
> Project: Flink
>  Issue Type: New Feature
>  Components: Table API
>Reporter: Timo Walther
>Assignee: Timo Walther
>Priority: Critical
>
> Since FLINK-3786 has been solved, we can now start integrating 
> BigDecimal/BigInteger into the Table API.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15327591#comment-15327591
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

Github user fhueske commented on the issue:

https://github.com/apache/flink/pull/2088
  
Think we also need aggregation functions for `DECIMAL` otherwise this won't 
work:
```
SELECT sum(myInt * 1.23) FROM MyTable
```


> Add BigDecimal/BigInteger support to Table API
> --
>
> Key: FLINK-3859
> URL: https://issues.apache.org/jira/browse/FLINK-3859
> Project: Flink
>  Issue Type: New Feature
>  Components: Table API
>Reporter: Timo Walther
>Assignee: Timo Walther
>Priority: Critical
>
> Since FLINK-3786 has been solved, we can now start integrating 
> BigDecimal/BigInteger into the Table API.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15327549#comment-15327549
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

Github user fhueske commented on the issue:

https://github.com/apache/flink/pull/2088
  
Thanks for the PR, @twalthr! Looks mostly good. I found a few cases that 
needs to be fix.

We also should think about how to handle SQL `DECIMAL` types with fixed 
precision / scale, e.g., how to handle something like `SELECT myDouble AS 
DECIMAL(4,2)`. Do you think this could be easily added with this PR or rather 
be fix in a later issue?


> Add BigDecimal/BigInteger support to Table API
> --
>
> Key: FLINK-3859
> URL: https://issues.apache.org/jira/browse/FLINK-3859
> Project: Flink
>  Issue Type: New Feature
>  Components: Table API
>Reporter: Timo Walther
>Assignee: Timo Walther
>Priority: Critical
>
> Since FLINK-3786 has been solved, we can now start integrating 
> BigDecimal/BigInteger into the Table API.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15327547#comment-15327547
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

Github user fhueske commented on a diff in the pull request:

https://github.com/apache/flink/pull/2088#discussion_r66807225
  
--- Diff: 
flink-libraries/flink-table/src/test/scala/org/apache/flink/api/scala/expression/DecimalTypeTest.scala
 ---
@@ -0,0 +1,262 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.api.scala.expression
+
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo._
+import org.apache.flink.api.common.typeinfo.TypeInformation
+import org.apache.flink.api.scala.expression.utils.ExpressionTestBase
+import org.apache.flink.api.scala.table._
+import org.apache.flink.api.table.Row
+import org.apache.flink.api.table.expressions.Literal
+import org.apache.flink.api.table.typeutils.RowTypeInfo
+import org.junit.Test
+
+class DecimalTypeTest extends ExpressionTestBase {
+
+  @Test
+  def testDecimalLiterals(): Unit = {
+// implicit double
+testAllApis(
+  11.2,
+  "11.2",
+  "11.2",
+  "11.2")
+
+// implicit double
+testAllApis(
+  0.7623533651719233,
+  "0.7623533651719233",
+  "0.7623533651719233",
+  "0.7623533651719233")
+
+// explicit decimal (with precision of 19)
+testAllApis(
+  BigDecimal("1234567891234567891"),
+  "1234567891234567891p",
+  "1234567891234567891",
+  "1234567891234567891")
+
+// explicit decimal (high precision, not SQL compliant)
+testTableApi(
+  BigDecimal("123456789123456789123456789"),
+  "123456789123456789123456789p",
+  "123456789123456789123456789")
+
+// explicit decimal (high precision, not SQL compliant)
+testTableApi(
+  BigDecimal("12.3456789123456789123456789"),
+  "12.3456789123456789123456789p",
+  "12.3456789123456789123456789")
+  }
+
+  @Test
+  def testDecimalBorders(): Unit = {
+testAllApis(
+  Double.MaxValue,
+  Double.MaxValue.toString,
+  Double.MaxValue.toString,
+  Double.MaxValue.toString)
+
+testAllApis(
+  Double.MinValue,
+  Double.MinValue.toString,
+  Double.MinValue.toString,
+  Double.MinValue.toString)
+
+testAllApis(
+  Double.MinValue.cast(FLOAT_TYPE_INFO),
+  s"${Double.MinValue}.cast(FLOAT)",
+  s"CAST(${Double.MinValue} AS FLOAT)",
+  Float.NegativeInfinity.toString)
+
+testAllApis(
+  Byte.MinValue.cast(BYTE_TYPE_INFO),
+  s"(${Byte.MinValue}).cast(BYTE)",
+  s"CAST(${Byte.MinValue} AS TINYINT)",
+  Byte.MinValue.toString)
+
+testAllApis(
+  Byte.MinValue.cast(BYTE_TYPE_INFO) - 1.cast(BYTE_TYPE_INFO),
+  s"(${Byte.MinValue}).cast(BYTE) - (1).cast(BYTE)",
+  s"CAST(${Byte.MinValue} AS TINYINT) - CAST(1 AS TINYINT)",
+  Byte.MaxValue.toString)
+
+testAllApis(
+  Short.MinValue.cast(SHORT_TYPE_INFO),
+  s"(${Short.MinValue}).cast(SHORT)",
+  s"CAST(${Short.MinValue} AS SMALLINT)",
+  Short.MinValue.toString)
+
+testAllApis(
+  Int.MinValue.cast(INT_TYPE_INFO) - 1,
+  s"(${Int.MinValue}).cast(INT) - 1",
+  s"CAST(${Int.MinValue} AS INT) - 1",
+  Int.MaxValue.toString)
+
+testAllApis(
+  Long.MinValue.cast(LONG_TYPE_INFO),
+  s"(${Long.MinValue}L).cast(LONG)",
+  s"CAST(${Long.MinValue} AS BIGINT)",
+  Long.MinValue.toString)
+  }
+
+  @Test
+  def testDecimalCasting(): Unit = {
+// from String
+testTableApi(
+  "123456789123456789123456789".cast(BIG_DEC_TYPE_INFO),
+  "'123456789123456789123456789'.cast(DECIMAL)",
+  

[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15327535#comment-15327535
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

Github user fhueske commented on a diff in the pull request:

https://github.com/apache/flink/pull/2088#discussion_r66805682
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/codegen/calls/ScalarOperators.scala
 ---
@@ -122,14 +125,14 @@ object ScalarOperators {
   right: GeneratedExpression)
 : GeneratedExpression = {
 generateOperatorIfNotNull(nullCheck, BOOLEAN_TYPE_INFO, left, right) {
-  if (isString(left) && isString(right)) {
+  if (isReference(left) && isReference(right)) {
 (leftTerm, rightTerm) => s"$leftTerm.compareTo($rightTerm) 
$operator 0"
   }
-  else if (isNumeric(left) && isNumeric(right)) {
+  else if (isNumeric(left.resultType) && isNumeric(right.resultType)) {
--- End diff --

If `left` or `right` is a `BigDecimal` invalid code is generated. 

> Caused by: org.codehaus.commons.compiler.CompileException: Line 64, 
Column 0: Cannot compare types "int" and "java.math.BigDecimal"

This happens if you replace the query in 
`FilterITCase.testFilterOnInteger()` by `SELECT * FROM MyTable WHERE a < 4.25`. 
`MyTable.a` is an `INTEGER` column and not auto-casted to `DECIMAL`. 
Auto-casting seems to work for expressions in the `SELECT` clause.


> Add BigDecimal/BigInteger support to Table API
> --
>
> Key: FLINK-3859
> URL: https://issues.apache.org/jira/browse/FLINK-3859
> Project: Flink
>  Issue Type: New Feature
>  Components: Table API
>Reporter: Timo Walther
>Assignee: Timo Walther
>Priority: Critical
>
> Since FLINK-3786 has been solved, we can now start integrating 
> BigDecimal/BigInteger into the Table API.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15327524#comment-15327524
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

Github user fhueske commented on a diff in the pull request:

https://github.com/apache/flink/pull/2088#discussion_r66804777
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/codegen/calls/ScalarFunctions.scala
 ---
@@ -143,15 +143,30 @@ object ScalarFunctions {
 new MultiTypeMethodCallGen(BuiltInMethods.ABS))
 
   addSqlFunction(
+ABS,
+Seq(BIG_DEC_TYPE_INFO),
+new MultiTypeMethodCallGen(BuiltInMethods.ABS_DEC))
+
+  addSqlFunction(
--- End diff --

Just wondering, why are there no functions for `FLOAT`? Are they handled by 
the `DOUBLE` functions?


> Add BigDecimal/BigInteger support to Table API
> --
>
> Key: FLINK-3859
> URL: https://issues.apache.org/jira/browse/FLINK-3859
> Project: Flink
>  Issue Type: New Feature
>  Components: Table API
>Reporter: Timo Walther
>Assignee: Timo Walther
>Priority: Critical
>
> Since FLINK-3786 has been solved, we can now start integrating 
> BigDecimal/BigInteger into the Table API.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15327518#comment-15327518
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

Github user fhueske commented on a diff in the pull request:

https://github.com/apache/flink/pull/2088#discussion_r66804568
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/codegen/CodeGenUtils.scala
 ---
@@ -97,11 +97,26 @@ object CodeGenUtils {
 case _ => "null"
   }
 
-  def requireNumeric(genExpr: GeneratedExpression) = genExpr.resultType 
match {
-case nti: NumericTypeInfo[_] => // ok
-case _ => throw new CodeGenException("Numeric expression type 
expected.")
+  def superPrimitive(typeInfo: TypeInformation[_]): String = typeInfo 
match {
+case _: FractionalTypeInfo[_] => "double"
+case _ => "long"
   }
 
+  // 
--
+
+  def requireNumeric(genExpr: GeneratedExpression) =
+if (!TypeCheckUtils.isNumeric(genExpr.resultType)) {
+  throw new CodeGenException("Numeric expression type expected, but 
was " +
+s"'${genExpr.resultType}'")
+}
+
+  def requireNumericOrComparable(genExpr: GeneratedExpression) =
--- End diff --

Rename to `requireComparable()`?


> Add BigDecimal/BigInteger support to Table API
> --
>
> Key: FLINK-3859
> URL: https://issues.apache.org/jira/browse/FLINK-3859
> Project: Flink
>  Issue Type: New Feature
>  Components: Table API
>Reporter: Timo Walther
>Assignee: Timo Walther
>Priority: Critical
>
> Since FLINK-3786 has been solved, we can now start integrating 
> BigDecimal/BigInteger into the Table API.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (FLINK-3859) Add BigDecimal/BigInteger support to Table API

2016-06-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-3859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15322577#comment-15322577
 ] 

ASF GitHub Bot commented on FLINK-3859:
---

GitHub user twalthr opened a pull request:

https://github.com/apache/flink/pull/2088

[FLINK-3859] [table] Add BigDecimal/BigInteger support to Table API

- [x] General
  - The pull request references the related JIRA issue ("[FLINK-XXX] Jira 
title text")
  - The pull request addresses only one issue
  - Each commit in the PR has a meaningful commit message (including the 
JIRA id)

- [x] Documentation
  - Documentation has been added for new functionality
  - Old documentation affected by the pull request has been updated
  - JavaDoc for public methods has been added

- [x] Tests & Build
  - Functionality added by the pull request is covered by tests
  - `mvn clean verify` has been executed successfully locally or a Travis 
build has passed

This PR introduces the BigDecimal type (and thus also BigInteger) to the 
Table API. Basic arithmetic operations as well as ABS, FLOOR and CEIL are now 
possible. I fixed several bugs and refactored some code parts (e.g. I 
introduced an ExpressionTestBase). 

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/twalthr/flink TableApiBigDecBigIntIntegration

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/flink/pull/2088.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #2088


commit 79ebde101c48f5718a35638283d5e953a3b0bb0e
Author: twalthr 
Date:   2016-05-09T10:10:57Z

[FLINK-3859] [table] Add BigDecimal/BigInteger support to Table API




> Add BigDecimal/BigInteger support to Table API
> --
>
> Key: FLINK-3859
> URL: https://issues.apache.org/jira/browse/FLINK-3859
> Project: Flink
>  Issue Type: New Feature
>  Components: Table API
>Reporter: Timo Walther
>Assignee: Timo Walther
>Priority: Critical
>
> Since FLINK-3786 has been solved, we can now start integrating 
> BigDecimal/BigInteger into the Table API.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)