[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16566761#comment-16566761 ] ASF GitHub Bot commented on FLINK-9688: --- asfgit closed pull request #6223: [FLINK-9688] [table] ATAN2 sql function support URL: https://github.com/apache/flink/pull/6223 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/docs/dev/table/sql.md b/docs/dev/table/sql.md index 3d6f0700184..19fd18a1589 100644 --- a/docs/dev/table/sql.md +++ b/docs/dev/table/sql.md @@ -1510,6 +1510,17 @@ ATAN(numeric) + + +{% highlight text %} +ATAN2(numeric, numeric) +{% endhighlight %} + + +Calculates the arc tangent of a given coordinate. + + + {% highlight text %} diff --git a/docs/dev/table/tableApi.md b/docs/dev/table/tableApi.md index a7b9522c015..87f708ed35b 100644 --- a/docs/dev/table/tableApi.md +++ b/docs/dev/table/tableApi.md @@ -2184,6 +2184,17 @@ NUMERIC.atan() + + +{% highlight java %} +atan2(NUMERIC, NUMERIC) +{% endhighlight %} + + +Calculates the arc tangent of a given coordinate. + + + {% highlight java %} @@ -3748,6 +3759,17 @@ NUMERIC.atan() + + +{% highlight scala %} +atan2(NUMERIC, NUMERIC) +{% endhighlight %} + + +Calculates the arc tangent of a given coordinate. + + + {% highlight scala %} diff --git a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/scala/expressionDsl.scala b/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/scala/expressionDsl.scala index b0bc5b66c33..868509b694f 100644 --- a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/scala/expressionDsl.scala +++ b/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/scala/expressionDsl.scala @@ -1180,6 +1180,15 @@ object concat { } } +/** + * Calculates the arc tangent of a given coordinate. + */ +object atan2 { + def apply(expr: Expression, other: Expression): Expression = { +Atan2(expr, other) + } +} + /** * Returns the string that results from concatenating the arguments and separator. * Returns NULL If the separator is NULL. diff --git a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/BuiltInMethods.scala b/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/BuiltInMethods.scala index ea4f0fd2f92..c357c17ed34 100644 --- a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/BuiltInMethods.scala +++ b/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/BuiltInMethods.scala @@ -73,6 +73,12 @@ object BuiltInMethods { val ATAN = Types.lookupMethod(classOf[Math], "atan", classOf[Double]) val ATAN_DEC = Types.lookupMethod(classOf[SqlFunctions], "atan", classOf[JBigDecimal]) + val ATAN2 = Types.lookupMethod(classOf[Math], "atan2", classOf[Double], classOf[Double]) + val ATAN2_DEC = Types.lookupMethod( +classOf[ScalarFunctions], "atan2", classOf[Double], classOf[JBigDecimal]) + val ATAN2_DEC_DEC = Types.lookupMethod(classOf[ScalarFunctions], "atan2", +classOf[JBigDecimal], classOf[JBigDecimal]) + val DEGREES = Types.lookupMethod(classOf[Math], "toDegrees", classOf[Double]) val DEGREES_DEC = Types.lookupMethod(classOf[SqlFunctions], "degrees", classOf[JBigDecimal]) diff --git a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/FunctionGenerator.scala b/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/FunctionGenerator.scala index bd75617f474..33472548cd0 100644 --- a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/FunctionGenerator.scala +++ b/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/FunctionGenerator.scala @@ -300,6 +300,24 @@ object FunctionGenerator { DOUBLE_TYPE_INFO, BuiltInMethods.ATAN_DEC) + addSqlFunctionMethod( +ATAN2, +Seq(DOUBLE_TYPE_INFO, DOUBLE_TYPE_INFO), +DOUBLE_TYPE_INFO, +BuiltInMethods.ATAN2) + + addSqlFunctionMethod( +ATAN2, +Seq(DOUBLE_TYPE_INFO, BIG_DEC_TYPE_INFO), +DOUBLE_TYPE_INFO, +BuiltInMethods.ATAN2_DEC) + + addSqlFunctionMethod( +ATAN2, +Seq(BIG_DEC_TYPE_INFO, BIG_DEC_TYPE_INFO), +DOUBLE_TYPE_INFO, +BuiltInMethods.ATAN2_DEC_DEC) + addSqlFunctionMethod( DEGREES, Seq(DOUBLE_TYPE_INFO), diff --git a/flink-libraries/flink-table/src/main/scala/org/apache/
[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16566732#comment-16566732 ] ASF GitHub Bot commented on FLINK-9688: --- twalthr commented on a change in pull request #6223: [FLINK-9688] [table] ATAN2 sql function support URL: https://github.com/apache/flink/pull/6223#discussion_r207212692 ## File path: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/expressions/mathExpressions.scala ## @@ -243,6 +243,19 @@ case class Atan(child: Expression) extends UnaryExpression { } } +case class Atan2(left: Expression, right: Expression) extends BinaryExpression with InputTypeSpec { Review comment: We should not use `InputTypeSpec` here. It forces a certain type which results in BigDecimal even for double types. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > ATAN2 Sql Function support > -- > > Key: FLINK-9688 > URL: https://issues.apache.org/jira/browse/FLINK-9688 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL >Reporter: Sergey Nuyanzin >Assignee: Sergey Nuyanzin >Priority: Minor > Labels: pull-request-available > > simple query fails {code} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, > config()); > DataSet> ds = > CollectionDataSets.get3TupleDataSet(env); > tableEnv.registerDataSet("t1", ds, "x, y, z"); > String sqlQuery = "SELECT atan2(1,2)"; > Table result = tableEnv.sqlQuery(sqlQuery); > {code} > while at the same time Calcite supports it and in Calcite's sqlline it works > like {noformat} > 0: jdbc:calcite:model=target/test-classes/mod> select atan2(1,2); > +-+ > | EXPR$0 | > +-+ > | 0.4636476090008061 | > +-+ > 1 row selected (0.173 seconds) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16531610#comment-16531610 ] ASF GitHub Bot commented on FLINK-9688: --- Github user snuyanzin commented on a diff in the pull request: https://github.com/apache/flink/pull/6223#discussion_r199866207 --- Diff: docs/dev/table/tableApi.md --- @@ -2184,6 +2184,17 @@ NUMERIC.atan() + + +{% highlight java %} +NUMERIC.atan2(NUMERIC) --- End diff -- Agree I changed the syntax to `atan2(Numeric, Numeric)` > ATAN2 Sql Function support > -- > > Key: FLINK-9688 > URL: https://issues.apache.org/jira/browse/FLINK-9688 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL >Reporter: Sergey Nuyanzin >Assignee: Sergey Nuyanzin >Priority: Minor > Labels: pull-request-available > > simple query fails {code} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, > config()); > DataSet> ds = > CollectionDataSets.get3TupleDataSet(env); > tableEnv.registerDataSet("t1", ds, "x, y, z"); > String sqlQuery = "SELECT atan2(1,2)"; > Table result = tableEnv.sqlQuery(sqlQuery); > {code} > while at the same time Calcite supports it and in Calcite's sqlline it works > like {noformat} > 0: jdbc:calcite:model=target/test-classes/mod> select atan2(1,2); > +-+ > | EXPR$0 | > +-+ > | 0.4636476090008061 | > +-+ > 1 row selected (0.173 seconds) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16531099#comment-16531099 ] ASF GitHub Bot commented on FLINK-9688: --- Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/6223#discussion_r199743600 --- Diff: docs/dev/table/tableApi.md --- @@ -2184,6 +2184,17 @@ NUMERIC.atan() + + +{% highlight java %} +NUMERIC.atan2(NUMERIC) --- End diff -- given that both parameters are equally important, we might want to change the syntax to `atan2(Numeric, Numeric)`. IMO, that would be more intuitive. What do you think? > ATAN2 Sql Function support > -- > > Key: FLINK-9688 > URL: https://issues.apache.org/jira/browse/FLINK-9688 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL >Reporter: Sergey Nuyanzin >Assignee: Sergey Nuyanzin >Priority: Minor > Labels: pull-request-available > > simple query fails {code} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, > config()); > DataSet> ds = > CollectionDataSets.get3TupleDataSet(env); > tableEnv.registerDataSet("t1", ds, "x, y, z"); > String sqlQuery = "SELECT atan2(1,2)"; > Table result = tableEnv.sqlQuery(sqlQuery); > {code} > while at the same time Calcite supports it and in Calcite's sqlline it works > like {noformat} > 0: jdbc:calcite:model=target/test-classes/mod> select atan2(1,2); > +-+ > | EXPR$0 | > +-+ > | 0.4636476090008061 | > +-+ > 1 row selected (0.173 seconds) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16530946#comment-16530946 ] ASF GitHub Bot commented on FLINK-9688: --- Github user snuyanzin commented on the issue: https://github.com/apache/flink/pull/6223 @fhueske @hequn8128 @yanghua thank you very much for your review and comments I did almost all the corrections except one related to atan2 description So I have a question: as @hequn8128 wrote > I checked the [wiki](https://en.wikipedia.org/wiki/Atan2) about atan2, it said: The atan2 function calculates one unique arc tangent value from two variables y and x. So, would it be better of two variables? atan2(y,x) can be the arc tangent of (x,y) or (nx, ny). At the same time I checked [Calcite's definition](https://calcite.apache.org/docs/reference.html) of it: _ATAN2(numeric, numeric) | Returns the arc tangent of the numeric coordinates._ What do you think what is more suitable? > ATAN2 Sql Function support > -- > > Key: FLINK-9688 > URL: https://issues.apache.org/jira/browse/FLINK-9688 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL >Reporter: Sergey Nuyanzin >Assignee: Sergey Nuyanzin >Priority: Minor > Labels: pull-request-available > > simple query fails {code} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, > config()); > DataSet> ds = > CollectionDataSets.get3TupleDataSet(env); > tableEnv.registerDataSet("t1", ds, "x, y, z"); > String sqlQuery = "SELECT atan2(1,2)"; > Table result = tableEnv.sqlQuery(sqlQuery); > {code} > while at the same time Calcite supports it and in Calcite's sqlline it works > like {noformat} > 0: jdbc:calcite:model=target/test-classes/mod> select atan2(1,2); > +-+ > | EXPR$0 | > +-+ > | 0.4636476090008061 | > +-+ > 1 row selected (0.173 seconds) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16530104#comment-16530104 ] ASF GitHub Bot commented on FLINK-9688: --- Github user snuyanzin commented on a diff in the pull request: https://github.com/apache/flink/pull/6223#discussion_r199543936 --- Diff: docs/dev/table/sql.md --- @@ -1510,6 +1510,17 @@ ATAN(numeric) + + +{% highlight text %} +ATAN2(numeric, numeric) +{% endhighlight %} + + +Calculates the arc tangent of a given coordinate. --- End diff -- Hello @hequn8128! The idea about coordinates comes from Math.atan2 + Calcite's definition here [1] ATAN2(numeric, numeric) | Returns the arc tangent of the numeric coordinates. Does it make sense to take the same wording as Calcite has? [1] https://calcite.apache.org/docs/reference.html > ATAN2 Sql Function support > -- > > Key: FLINK-9688 > URL: https://issues.apache.org/jira/browse/FLINK-9688 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL >Reporter: Sergey Nuyanzin >Assignee: Sergey Nuyanzin >Priority: Minor > Labels: pull-request-available > > simple query fails {code} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, > config()); > DataSet> ds = > CollectionDataSets.get3TupleDataSet(env); > tableEnv.registerDataSet("t1", ds, "x, y, z"); > String sqlQuery = "SELECT atan2(1,2)"; > Table result = tableEnv.sqlQuery(sqlQuery); > {code} > while at the same time Calcite supports it and in Calcite's sqlline it works > like {noformat} > 0: jdbc:calcite:model=target/test-classes/mod> select atan2(1,2); > +-+ > | EXPR$0 | > +-+ > | 0.4636476090008061 | > +-+ > 1 row selected (0.173 seconds) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16530083#comment-16530083 ] ASF GitHub Bot commented on FLINK-9688: --- Github user hequn8128 commented on a diff in the pull request: https://github.com/apache/flink/pull/6223#discussion_r199537675 --- Diff: docs/dev/table/sql.md --- @@ -1510,6 +1510,17 @@ ATAN(numeric) + + +{% highlight text %} +ATAN2(numeric) +{% endhighlight %} + + +Calculates the arc tangent of a given coordinates. --- End diff -- I checked the [wiki](https://en.wikipedia.org/wiki/Atan2) about atan2, it said: The atan2 function calculates one unique arc tangent value from two variables y and x. So, would it be better `of two variables`? atan2(y,x) can be the arc tangent of (x,y) or (nx, ny). > ATAN2 Sql Function support > -- > > Key: FLINK-9688 > URL: https://issues.apache.org/jira/browse/FLINK-9688 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL >Reporter: Sergey Nuyanzin >Assignee: Sergey Nuyanzin >Priority: Minor > Labels: pull-request-available > > simple query fails {code} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, > config()); > DataSet> ds = > CollectionDataSets.get3TupleDataSet(env); > tableEnv.registerDataSet("t1", ds, "x, y, z"); > String sqlQuery = "SELECT atan2(1,2)"; > Table result = tableEnv.sqlQuery(sqlQuery); > {code} > while at the same time Calcite supports it and in Calcite's sqlline it works > like {noformat} > 0: jdbc:calcite:model=target/test-classes/mod> select atan2(1,2); > +-+ > | EXPR$0 | > +-+ > | 0.4636476090008061 | > +-+ > 1 row selected (0.173 seconds) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16530081#comment-16530081 ] ASF GitHub Bot commented on FLINK-9688: --- Github user hequn8128 commented on a diff in the pull request: https://github.com/apache/flink/pull/6223#discussion_r199537075 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/FunctionGenerator.scala --- @@ -300,6 +300,24 @@ object FunctionGenerator { DOUBLE_TYPE_INFO, BuiltInMethods.ATAN_DEC) + addSqlFunctionMethod( +ATAN2, +Seq(DOUBLE_TYPE_INFO, DOUBLE_TYPE_INFO), +DOUBLE_TYPE_INFO, +BuiltInMethods.ATAN2) + + addSqlFunctionMethod( +ATAN2, +Seq(DOUBLE_TYPE_INFO, BIG_DEC_TYPE_INFO), +DOUBLE_TYPE_INFO, +BuiltInMethods.ATAN2_DEC) + + addSqlFunctionMethod( +ATAN2, +Seq(BIG_DEC_TYPE_INFO, BIG_DEC_TYPE_INFO), +DOUBLE_TYPE_INFO, +BuiltInMethods.ATAN2_DEC) --- End diff -- BuiltInMethods.ATAN2_DEC_DEC > ATAN2 Sql Function support > -- > > Key: FLINK-9688 > URL: https://issues.apache.org/jira/browse/FLINK-9688 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL >Reporter: Sergey Nuyanzin >Assignee: Sergey Nuyanzin >Priority: Minor > Labels: pull-request-available > > simple query fails {code} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, > config()); > DataSet> ds = > CollectionDataSets.get3TupleDataSet(env); > tableEnv.registerDataSet("t1", ds, "x, y, z"); > String sqlQuery = "SELECT atan2(1,2)"; > Table result = tableEnv.sqlQuery(sqlQuery); > {code} > while at the same time Calcite supports it and in Calcite's sqlline it works > like {noformat} > 0: jdbc:calcite:model=target/test-classes/mod> select atan2(1,2); > +-+ > | EXPR$0 | > +-+ > | 0.4636476090008061 | > +-+ > 1 row selected (0.173 seconds) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16530080#comment-16530080 ] ASF GitHub Bot commented on FLINK-9688: --- Github user hequn8128 commented on a diff in the pull request: https://github.com/apache/flink/pull/6223#discussion_r199537034 --- Diff: docs/dev/table/sql.md --- @@ -1510,6 +1510,17 @@ ATAN(numeric) + + +{% highlight text %} +ATAN2(numeric, numeric) +{% endhighlight %} + + +Calculates the arc tangent of a given coordinate. --- End diff -- I checked the [wiki](https://en.wikipedia.org/wiki/Atan2) about atan2, it said: The atan2 function calculates one unique arc tangent value from two variables y and x. So, would it be better `of two variables`? atan2(y,x) can be the arc tangent of (x,y) or (nx, ny). > ATAN2 Sql Function support > -- > > Key: FLINK-9688 > URL: https://issues.apache.org/jira/browse/FLINK-9688 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL >Reporter: Sergey Nuyanzin >Assignee: Sergey Nuyanzin >Priority: Minor > Labels: pull-request-available > > simple query fails {code} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, > config()); > DataSet> ds = > CollectionDataSets.get3TupleDataSet(env); > tableEnv.registerDataSet("t1", ds, "x, y, z"); > String sqlQuery = "SELECT atan2(1,2)"; > Table result = tableEnv.sqlQuery(sqlQuery); > {code} > while at the same time Calcite supports it and in Calcite's sqlline it works > like {noformat} > 0: jdbc:calcite:model=target/test-classes/mod> select atan2(1,2); > +-+ > | EXPR$0 | > +-+ > | 0.4636476090008061 | > +-+ > 1 row selected (0.173 seconds) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16529952#comment-16529952 ] ASF GitHub Bot commented on FLINK-9688: --- Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/6223#discussion_r199501001 --- Diff: docs/dev/table/tableApi.md --- @@ -2184,6 +2184,17 @@ NUMERIC.atan() + + +{% highlight java %} +NUMERIC.atan2() +{% endhighlight %} + + +Calculates the arc tangent of a given coordinates. --- End diff -- see above > ATAN2 Sql Function support > -- > > Key: FLINK-9688 > URL: https://issues.apache.org/jira/browse/FLINK-9688 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL >Reporter: Sergey Nuyanzin >Assignee: Sergey Nuyanzin >Priority: Minor > Labels: pull-request-available > > simple query fails {code} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, > config()); > DataSet> ds = > CollectionDataSets.get3TupleDataSet(env); > tableEnv.registerDataSet("t1", ds, "x, y, z"); > String sqlQuery = "SELECT atan2(1,2)"; > Table result = tableEnv.sqlQuery(sqlQuery); > {code} > while at the same time Calcite supports it and in Calcite's sqlline it works > like {noformat} > 0: jdbc:calcite:model=target/test-classes/mod> select atan2(1,2); > +-+ > | EXPR$0 | > +-+ > | 0.4636476090008061 | > +-+ > 1 row selected (0.173 seconds) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16529955#comment-16529955 ] ASF GitHub Bot commented on FLINK-9688: --- Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/6223#discussion_r199501083 --- Diff: docs/dev/table/tableApi.md --- @@ -3748,6 +3759,17 @@ NUMERIC.atan() + + +{% highlight scala %} +NUMERIC.atan2() --- End diff -- should be `NUMERIC.atan2(NUMERIC)`. > ATAN2 Sql Function support > -- > > Key: FLINK-9688 > URL: https://issues.apache.org/jira/browse/FLINK-9688 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL >Reporter: Sergey Nuyanzin >Assignee: Sergey Nuyanzin >Priority: Minor > Labels: pull-request-available > > simple query fails {code} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, > config()); > DataSet> ds = > CollectionDataSets.get3TupleDataSet(env); > tableEnv.registerDataSet("t1", ds, "x, y, z"); > String sqlQuery = "SELECT atan2(1,2)"; > Table result = tableEnv.sqlQuery(sqlQuery); > {code} > while at the same time Calcite supports it and in Calcite's sqlline it works > like {noformat} > 0: jdbc:calcite:model=target/test-classes/mod> select atan2(1,2); > +-+ > | EXPR$0 | > +-+ > | 0.4636476090008061 | > +-+ > 1 row selected (0.173 seconds) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16529957#comment-16529957 ] ASF GitHub Bot commented on FLINK-9688: --- Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/6223#discussion_r199504092 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/expressions/mathExpressions.scala --- @@ -243,6 +243,16 @@ case class Atan(child: Expression) extends UnaryExpression { } } +case class Atan2(left: Expression, right: Expression) extends BinaryExpression { --- End diff -- No input validation? override `expectedTypes` or `validateInput()` > ATAN2 Sql Function support > -- > > Key: FLINK-9688 > URL: https://issues.apache.org/jira/browse/FLINK-9688 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL >Reporter: Sergey Nuyanzin >Assignee: Sergey Nuyanzin >Priority: Minor > Labels: pull-request-available > > simple query fails {code} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, > config()); > DataSet> ds = > CollectionDataSets.get3TupleDataSet(env); > tableEnv.registerDataSet("t1", ds, "x, y, z"); > String sqlQuery = "SELECT atan2(1,2)"; > Table result = tableEnv.sqlQuery(sqlQuery); > {code} > while at the same time Calcite supports it and in Calcite's sqlline it works > like {noformat} > 0: jdbc:calcite:model=target/test-classes/mod> select atan2(1,2); > +-+ > | EXPR$0 | > +-+ > | 0.4636476090008061 | > +-+ > 1 row selected (0.173 seconds) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16529951#comment-16529951 ] ASF GitHub Bot commented on FLINK-9688: --- Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/6223#discussion_r199500643 --- Diff: docs/dev/table/sql.md --- @@ -1510,6 +1510,17 @@ ATAN(numeric) + + +{% highlight text %} +ATAN2(numeric) --- End diff -- should be `ATAN2(numeric, numeric)` > ATAN2 Sql Function support > -- > > Key: FLINK-9688 > URL: https://issues.apache.org/jira/browse/FLINK-9688 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL >Reporter: Sergey Nuyanzin >Assignee: Sergey Nuyanzin >Priority: Minor > Labels: pull-request-available > > simple query fails {code} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, > config()); > DataSet> ds = > CollectionDataSets.get3TupleDataSet(env); > tableEnv.registerDataSet("t1", ds, "x, y, z"); > String sqlQuery = "SELECT atan2(1,2)"; > Table result = tableEnv.sqlQuery(sqlQuery); > {code} > while at the same time Calcite supports it and in Calcite's sqlline it works > like {noformat} > 0: jdbc:calcite:model=target/test-classes/mod> select atan2(1,2); > +-+ > | EXPR$0 | > +-+ > | 0.4636476090008061 | > +-+ > 1 row selected (0.173 seconds) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16529953#comment-16529953 ] ASF GitHub Bot commented on FLINK-9688: --- Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/6223#discussion_r199500973 --- Diff: docs/dev/table/tableApi.md --- @@ -2184,6 +2184,17 @@ NUMERIC.atan() + + +{% highlight java %} +NUMERIC.atan2() --- End diff -- should be `NUMERIC.atan2(NUMERIC)` > ATAN2 Sql Function support > -- > > Key: FLINK-9688 > URL: https://issues.apache.org/jira/browse/FLINK-9688 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL >Reporter: Sergey Nuyanzin >Assignee: Sergey Nuyanzin >Priority: Minor > Labels: pull-request-available > > simple query fails {code} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, > config()); > DataSet> ds = > CollectionDataSets.get3TupleDataSet(env); > tableEnv.registerDataSet("t1", ds, "x, y, z"); > String sqlQuery = "SELECT atan2(1,2)"; > Table result = tableEnv.sqlQuery(sqlQuery); > {code} > while at the same time Calcite supports it and in Calcite's sqlline it works > like {noformat} > 0: jdbc:calcite:model=target/test-classes/mod> select atan2(1,2); > +-+ > | EXPR$0 | > +-+ > | 0.4636476090008061 | > +-+ > 1 row selected (0.173 seconds) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16529956#comment-16529956 ] ASF GitHub Bot commented on FLINK-9688: --- Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/6223#discussion_r199501131 --- Diff: docs/dev/table/tableApi.md --- @@ -3748,6 +3759,17 @@ NUMERIC.atan() + + +{% highlight scala %} +NUMERIC.atan2() +{% endhighlight %} + + +Calculates the tangent of a given coordinates. --- End diff -- see above > ATAN2 Sql Function support > -- > > Key: FLINK-9688 > URL: https://issues.apache.org/jira/browse/FLINK-9688 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL >Reporter: Sergey Nuyanzin >Assignee: Sergey Nuyanzin >Priority: Minor > Labels: pull-request-available > > simple query fails {code} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, > config()); > DataSet> ds = > CollectionDataSets.get3TupleDataSet(env); > tableEnv.registerDataSet("t1", ds, "x, y, z"); > String sqlQuery = "SELECT atan2(1,2)"; > Table result = tableEnv.sqlQuery(sqlQuery); > {code} > while at the same time Calcite supports it and in Calcite's sqlline it works > like {noformat} > 0: jdbc:calcite:model=target/test-classes/mod> select atan2(1,2); > +-+ > | EXPR$0 | > +-+ > | 0.4636476090008061 | > +-+ > 1 row selected (0.173 seconds) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16529954#comment-16529954 ] ASF GitHub Bot commented on FLINK-9688: --- Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/6223#discussion_r199500813 --- Diff: docs/dev/table/sql.md --- @@ -1510,6 +1510,17 @@ ATAN(numeric) + + +{% highlight text %} +ATAN2(numeric) +{% endhighlight %} + + +Calculates the arc tangent of a given coordinates. --- End diff -- should be `of a given coordinate.` (-s)? > ATAN2 Sql Function support > -- > > Key: FLINK-9688 > URL: https://issues.apache.org/jira/browse/FLINK-9688 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL >Reporter: Sergey Nuyanzin >Assignee: Sergey Nuyanzin >Priority: Minor > Labels: pull-request-available > > simple query fails {code} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, > config()); > DataSet> ds = > CollectionDataSets.get3TupleDataSet(env); > tableEnv.registerDataSet("t1", ds, "x, y, z"); > String sqlQuery = "SELECT atan2(1,2)"; > Table result = tableEnv.sqlQuery(sqlQuery); > {code} > while at the same time Calcite supports it and in Calcite's sqlline it works > like {noformat} > 0: jdbc:calcite:model=target/test-classes/mod> select atan2(1,2); > +-+ > | EXPR$0 | > +-+ > | 0.4636476090008061 | > +-+ > 1 row selected (0.173 seconds) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16529282#comment-16529282 ] ASF GitHub Bot commented on FLINK-9688: --- Github user snuyanzin commented on a diff in the pull request: https://github.com/apache/flink/pull/6223#discussion_r199366673 --- Diff: flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ScalarFunctionsTest.scala --- @@ -,6 +,53 @@ class ScalarFunctionsTest extends ScalarTypesTestBase { math.atan(-0.123123132132132).toString) } + @Test + def testAtan2(): Unit = { +testAllApis( + 'f25.atan2('f26), + "f25.atan2(f26)", + "ATAN2(f25, f26)", + math.atan2(0.42.toByte, 0.toByte).toString) + + --- End diff -- Thank you for that catch. blank line removed > ATAN2 Sql Function support > -- > > Key: FLINK-9688 > URL: https://issues.apache.org/jira/browse/FLINK-9688 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL >Reporter: Sergey Nuyanzin >Assignee: Sergey Nuyanzin >Priority: Minor > Labels: pull-request-available > > simple query fails {code} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, > config()); > DataSet> ds = > CollectionDataSets.get3TupleDataSet(env); > tableEnv.registerDataSet("t1", ds, "x, y, z"); > String sqlQuery = "SELECT atan2(1,2)"; > Table result = tableEnv.sqlQuery(sqlQuery); > {code} > while at the same time Calcite supports it and in Calcite's sqlline it works > like {noformat} > 0: jdbc:calcite:model=target/test-classes/mod> select atan2(1,2); > +-+ > | EXPR$0 | > +-+ > | 0.4636476090008061 | > +-+ > 1 row selected (0.173 seconds) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16529278#comment-16529278 ] ASF GitHub Bot commented on FLINK-9688: --- Github user yanghua commented on a diff in the pull request: https://github.com/apache/flink/pull/6223#discussion_r199365966 --- Diff: flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ScalarFunctionsTest.scala --- @@ -,6 +,53 @@ class ScalarFunctionsTest extends ScalarTypesTestBase { math.atan(-0.123123132132132).toString) } + @Test + def testAtan2(): Unit = { +testAllApis( + 'f25.atan2('f26), + "f25.atan2(f26)", + "ATAN2(f25, f26)", + math.atan2(0.42.toByte, 0.toByte).toString) + + --- End diff -- Remove this blank line would be better~ > ATAN2 Sql Function support > -- > > Key: FLINK-9688 > URL: https://issues.apache.org/jira/browse/FLINK-9688 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL >Reporter: Sergey Nuyanzin >Assignee: Sergey Nuyanzin >Priority: Minor > Labels: pull-request-available > > simple query fails {code} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, > config()); > DataSet> ds = > CollectionDataSets.get3TupleDataSet(env); > tableEnv.registerDataSet("t1", ds, "x, y, z"); > String sqlQuery = "SELECT atan2(1,2)"; > Table result = tableEnv.sqlQuery(sqlQuery); > {code} > while at the same time Calcite supports it and in Calcite's sqlline it works > like {noformat} > 0: jdbc:calcite:model=target/test-classes/mod> select atan2(1,2); > +-+ > | EXPR$0 | > +-+ > | 0.4636476090008061 | > +-+ > 1 row selected (0.173 seconds) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16526175#comment-16526175 ] Fabian Hueske commented on FLINK-9688: -- We aim of course for a large set of built-in function. So such new features are highly welcome. Thanks for creating this issue! > ATAN2 Sql Function support > -- > > Key: FLINK-9688 > URL: https://issues.apache.org/jira/browse/FLINK-9688 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL >Reporter: Sergey Nuyanzin >Assignee: Sergey Nuyanzin >Priority: Minor > > simple query fails {code} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, > config()); > DataSet> ds = > CollectionDataSets.get3TupleDataSet(env); > tableEnv.registerDataSet("t1", ds, "x, y, z"); > String sqlQuery = "SELECT atan2(1,2)"; > Table result = tableEnv.sqlQuery(sqlQuery); > {code} > while at the same time Calcite supports it and in Calcite's sqlline it works > like {noformat} > 0: jdbc:calcite:model=target/test-classes/mod> select atan2(1,2); > +-+ > | EXPR$0 | > +-+ > | 0.4636476090008061 | > +-+ > 1 row selected (0.173 seconds) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16526166#comment-16526166 ] Sergey Nuyanzin commented on FLINK-9688: ok I see, thank you for clarification > ATAN2 Sql Function support > -- > > Key: FLINK-9688 > URL: https://issues.apache.org/jira/browse/FLINK-9688 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL >Reporter: Sergey Nuyanzin >Assignee: Sergey Nuyanzin >Priority: Minor > > simple query fails {code} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, > config()); > DataSet> ds = > CollectionDataSets.get3TupleDataSet(env); > tableEnv.registerDataSet("t1", ds, "x, y, z"); > String sqlQuery = "SELECT atan2(1,2)"; > Table result = tableEnv.sqlQuery(sqlQuery); > {code} > while at the same time Calcite supports it and in Calcite's sqlline it works > like {noformat} > 0: jdbc:calcite:model=target/test-classes/mod> select atan2(1,2); > +-+ > | EXPR$0 | > +-+ > | 0.4636476090008061 | > +-+ > 1 row selected (0.173 seconds) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-9688) ATAN2 Sql Function support
[ https://issues.apache.org/jira/browse/FLINK-9688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16526161#comment-16526161 ] Fabian Hueske commented on FLINK-9688: -- This is issue requests a new feature. The {{ATAN2}} is not support yet. Adding it is a new feature. It would be a bug if the function was already supported but computing an incorrect result. > ATAN2 Sql Function support > -- > > Key: FLINK-9688 > URL: https://issues.apache.org/jira/browse/FLINK-9688 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL >Reporter: Sergey Nuyanzin >Assignee: Sergey Nuyanzin >Priority: Minor > > simple query fails {code} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, > config()); > DataSet> ds = > CollectionDataSets.get3TupleDataSet(env); > tableEnv.registerDataSet("t1", ds, "x, y, z"); > String sqlQuery = "SELECT atan2(1,2)"; > Table result = tableEnv.sqlQuery(sqlQuery); > {code} > while at the same time Calcite supports it and in Calcite's sqlline it works > like {noformat} > 0: jdbc:calcite:model=target/test-classes/mod> select atan2(1,2); > +-+ > | EXPR$0 | > +-+ > | 0.4636476090008061 | > +-+ > 1 row selected (0.173 seconds) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)