You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "comphead (via GitHub)" <gi...@apache.org> on 2023/02/10 21:33:26 UTC

[GitHub] [arrow-datafusion] comphead opened a new pull request, #5245: Add SQL function overload LOG(base, x) for logarithm of x to base

comphead opened a new pull request, #5245:
URL: https://github.com/apache/arrow-datafusion/pull/5245

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #5206 .
   
   # Rationale for this change
   Add SQL function overload LOG(base, x) for logarithm of x to base
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are these changes tested?
   Test included
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   # Are there any user-facing changes?
   No
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #5245: Add SQL function overload LOG(base, x) for logarithm of x to base

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #5245:
URL: https://github.com/apache/arrow-datafusion/pull/5245#discussion_r1103624900


##########
datafusion/core/tests/sqllogictests/test_files/scalar.slt:
##########
@@ -0,0 +1,63 @@
+# 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.
+
+#############
+## Scalar Tests
+#############
+
+statement ok
+CREATE TABLE t1(
+  a INT,
+  b INT
+) as VALUES
+  (1, 100), 
+  (2, 1000), 
+  (3, 10000)
+;
+
+# log scalar function
+query IT rowsort
+select log(2, 64) a, log(100) b union all select log(2, 8), log(10);
+----
+3 1
+6 2
+
+# log scalar function
+query IT rowsort
+select log(a, 64) a, log(b), log(10, b) from t1;
+----
+3.7855785 4 4
+6 3 3
+Infinity 2 2
+
+# log scalar nulls
+query IT rowsort
+select log(null, 64) a, log(null) b
+----
+NULL NULL
+
+# log scalar nulls 1
+query IT rowsort
+select log(2, null) a, log(null) b
+----
+NULL NULL
+
+# log scalar nulls 2
+query IT rowsort
+select log(null, null) a, log(null) b
+----

Review Comment:
   Can you please add the test cases you identified in the PR here (log(0), log(1, 64)) as well to document the behavior and also file a ticket to document the discrepancy?
   



##########
datafusion/core/tests/sqllogictests/test_files/scalar.slt:
##########
@@ -0,0 +1,63 @@
+# 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.
+
+#############
+## Scalar Tests

Review Comment:
   ```suggestion
   ## Scalar Function Tests
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] comphead commented on pull request #5245: Add SQL function overload LOG(base, x) for logarithm of x to base

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on PR #5245:
URL: https://github.com/apache/arrow-datafusion/pull/5245#issuecomment-1426828382

   > > whereas PostgresSQL doesn't allow queries like that and fail the query
   > 
   > For anyone else who is curious, here is what postgres does with this query:
   > 
   > ```sql
   > postgres=# select log(0);
   > ERROR:  cannot take logarithm of zero
   > postgres=# select log(1, 64);
   > ERROR:  division by zero
   > ```
   
   @alamb would you like to solve edgecases as part of this PR or another one?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] comphead commented on pull request #5245: Add SQL function overload LOG(base, x) for logarithm of x to base

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on PR #5245:
URL: https://github.com/apache/arrow-datafusion/pull/5245#issuecomment-1426377741

   @stuartcarnie @alamb with `log` function we have some discrepancy with PG, its not brought up with this PR, it existed before
   
   ```
   ❯ select log(1, 64), log(0);
   +-------------------------+---------------+
   | log(Int64(1),Int64(64)) | log(Int64(0)) |
   +-------------------------+---------------+
   | inf                     | -inf          |
   +-------------------------+---------------+
   ```
   
   whereas PostgresSQL doesn't allow queries like that and fail the query


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] ursabot commented on pull request #5245: Add SQL function overload LOG(base, x) for logarithm of x to base

Posted by "ursabot (via GitHub)" <gi...@apache.org>.
ursabot commented on PR #5245:
URL: https://github.com/apache/arrow-datafusion/pull/5245#issuecomment-1427041322

   Benchmark runs are scheduled for baseline = 0f95966cc28d2ff55c225d8522027d61cdcdf4af and contender = 8a609dc207d3f08f26b1f8a04e16147d3573525b. 8a609dc207d3f08f26b1f8a04e16147d3573525b is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/6cdda80b04654277a571e2005060ae2a...f4bae2aff6304b88b31b107e1520c91a/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/8b15e44da1b14d5589daae6e9eeb5c28...73cfb1ed6e66414e90d502ba20f82265/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/590409b5b5ee49ae8246016b872a3538...11cad633bf774f2bb5a356440b772428/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/43f7896d01bc40139677135cd1f3fac5...2a8fbc4d39444296bdae3ab671928945/)
   Buildkite builds:
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on pull request #5245: Add SQL function overload LOG(base, x) for logarithm of x to base

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #5245:
URL: https://github.com/apache/arrow-datafusion/pull/5245#issuecomment-1426888584

   > @alamb would you like to solve edgecases as part of this PR or another one?
   
   A different one, please


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] stuartcarnie commented on pull request #5245: Add SQL function overload LOG(base, x) for logarithm of x to base

Posted by "stuartcarnie (via GitHub)" <gi...@apache.org>.
stuartcarnie commented on PR #5245:
URL: https://github.com/apache/arrow-datafusion/pull/5245#issuecomment-1426895779

   Looks great, thanks @comphead 🙏


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on pull request #5245: Add SQL function overload LOG(base, x) for logarithm of x to base

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #5245:
URL: https://github.com/apache/arrow-datafusion/pull/5245#issuecomment-1426764705

   > whereas PostgresSQL doesn't allow queries like that and fail the query
   
   For anyone else who is curious, here is what postgres does with this query:
   
   ```sql
   postgres=# select log(0);
   ERROR:  cannot take logarithm of zero
   postgres=# select log(1, 64);
   ERROR:  division by zero
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb merged pull request #5245: Add SQL function overload LOG(base, x) for logarithm of x to base

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #5245:
URL: https://github.com/apache/arrow-datafusion/pull/5245


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on pull request #5245: Add SQL function overload LOG(base, x) for logarithm of x to base

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #5245:
URL: https://github.com/apache/arrow-datafusion/pull/5245#issuecomment-1427040847

   Thanks again @comphead 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on pull request #5245: Add SQL function overload LOG(base, x) for logarithm of x to base

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #5245:
URL: https://github.com/apache/arrow-datafusion/pull/5245#issuecomment-1426888712

   Thanks @comphead  -- this looks really great. cc @stuartcarnie 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on pull request #5245: Add SQL function overload LOG(base, x) for logarithm of x to base

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #5245:
URL: https://github.com/apache/arrow-datafusion/pull/5245#issuecomment-1426770219

   Thank you very much for this contribution @comphead 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] comphead commented on a diff in pull request #5245: Add SQL function overload LOG(base, x) for logarithm of x to base

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #5245:
URL: https://github.com/apache/arrow-datafusion/pull/5245#discussion_r1103747211


##########
datafusion/core/tests/sqllogictests/test_files/scalar.slt:
##########
@@ -0,0 +1,63 @@
+# 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.
+
+#############
+## Scalar Tests

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] comphead commented on a diff in pull request #5245: Add SQL function overload LOG(base, x) for logarithm of x to base

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #5245:
URL: https://github.com/apache/arrow-datafusion/pull/5245#discussion_r1103747903


##########
datafusion/core/tests/sqllogictests/test_files/scalar.slt:
##########
@@ -0,0 +1,63 @@
+# 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.
+
+#############
+## Scalar Tests
+#############
+
+statement ok
+CREATE TABLE t1(
+  a INT,
+  b INT
+) as VALUES
+  (1, 100), 
+  (2, 1000), 
+  (3, 10000)
+;
+
+# log scalar function
+query IT rowsort
+select log(2, 64) a, log(100) b union all select log(2, 8), log(10);
+----
+3 1
+6 2
+
+# log scalar function
+query IT rowsort
+select log(a, 64) a, log(b), log(10, b) from t1;
+----
+3.7855785 4 4
+6 3 3
+Infinity 2 2
+
+# log scalar nulls
+query IT rowsort
+select log(null, 64) a, log(null) b
+----
+NULL NULL
+
+# log scalar nulls 1
+query IT rowsort
+select log(2, null) a, log(null) b
+----
+NULL NULL
+
+# log scalar nulls 2
+query IT rowsort
+select log(null, null) a, log(null) b
+----

Review Comment:
   Done, filed https://github.com/apache/arrow-datafusion/issues/5259



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org