You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/06/23 12:24:00 UTC
[jira] [Commented] (FLINK-6891) Add LOG(X) supported in SQL
[ https://issues.apache.org/jira/browse/FLINK-6891?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16060808#comment-16060808 ]
ASF GitHub Bot commented on FLINK-6891:
---------------------------------------
Github user twalthr commented on a diff in the pull request:
https://github.com/apache/flink/pull/4122#discussion_r123734574
--- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/scalarfunctions/MathScalarFunctions.scala ---
@@ -0,0 +1,52 @@
+/*
+ * 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.table.runtime.scalarfunctions
+
+/**
+ * All build-in math scalar functions.
+ */
+class MathScalarFunctions {}
+
+object MathScalarFunctions {
+ /**
+ * Returns the natural logarithm of "x".
+ */
+ def log(x: Double): Double = {
--- End diff --
Can't we just use the `Math.log` as the built in method? It would reduce complexity as we would not need a CallGenerator then.
> Add LOG(X) supported in SQL
> ---------------------------
>
> Key: FLINK-6891
> URL: https://issues.apache.org/jira/browse/FLINK-6891
> Project: Flink
> Issue Type: Sub-task
> Components: Table API & SQL
> Affects Versions: 1.4.0
> Reporter: sunjincheng
> Assignee: sunjincheng
>
> LOG(X), LOG(B,X)
> If called with one parameter, this function returns the natural logarithm of X. If X is less than or equal to 0.0E0, the function returns NULL and (as of MySQL 5.7.4) a warning “Invalid argument for logarithm” is reported.
> The inverse of this function (when called with a single argument) is the EXP() function.
> If called with two parameters, this function returns the logarithm of X to the base B. If X is less than or equal to 0, or if B is less than or equal to 1, then NULL is returned.
> * Example:
> LOG(2) -> 0.69314718055995
> LOG(-2) -> NULL
> LOG(2,65536) -> 16
> LOG(10,100) -> 2
> LOG(1,100) -> NULL
> * See more:
> ** [MySQL| https://dev.mysql.com/doc/refman/5.7/en/mathematical-functions.html#function_log]
> --NOTE-- In this JIRA. NULL case will throw IllegalArgumentException.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)