You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jiangzhx (via GitHub)" <gi...@apache.org> on 2023/06/09 09:15:28 UTC

[GitHub] [arrow-datafusion] jiangzhx opened a new pull request, #6608: move functions.rs to sqllogictests

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

   # 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 #.
   
   # Rationale for this change
   
   <!--
    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?
   
   <!--
   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?
   
   <!--
   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] jiangzhx commented on a diff in pull request #6608: Port remaining tests in functions.rs to sqllogictest

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


##########
datafusion/core/tests/sqllogictests/test_files/functions.slt:
##########
@@ -479,4 +479,90 @@ SELECT struct(c1,c2,c3,c4,a,b) from simple_struct_test
 {c0: 1, c1: 1, c2: 3.1, c3: 3.14, c4: str, c5: text}
 
 statement ok
-drop table simple_struct_test
\ No newline at end of file
+drop table simple_struct_test
+
+# create aggregate_test_100 table for functions test
+statement ok
+CREATE EXTERNAL TABLE aggregate_test_100 (
+  c1  VARCHAR NOT NULL,
+  c2  TINYINT NOT NULL,
+  c3  SMALLINT NOT NULL,
+  c4  SMALLINT,
+  c5  INT,
+  c6  BIGINT NOT NULL,
+  c7  SMALLINT NOT NULL,
+  c8  INT NOT NULL,
+  c9  BIGINT UNSIGNED NOT NULL,
+  c10 VARCHAR NOT NULL,
+  c11 FLOAT NOT NULL,
+  c12 DOUBLE NOT NULL,
+  c13 VARCHAR NOT NULL
+)
+STORED AS CSV
+WITH HEADER ROW
+LOCATION '../../testing/data/csv/aggregate_test_100.csv'
+
+
+# sqrt_f32_vs_f64
+query R
+SELECT avg(sqrt(c11)) FROM aggregate_test_100
+----
+0.6584408485889435
+
+query R
+SELECT avg(CAST(sqrt(c11) AS double)) FROM aggregate_test_100
+----
+0.6584408485889435
+
+query R
+SELECT avg(sqrt(CAST(c11 AS double))) FROM aggregate_test_100
+----
+0.6584408483418833
+
+statement ok
+drop table aggregate_test_100
+
+
+# case_sensitive_identifiers_functions
+statement ok
+create table t as values (
+    arrow_cast(2, 'Int8'),
+    arrow_cast(2, 'Int16'),
+    arrow_cast(2, 'Int32'),
+    arrow_cast(2, 'Int64'),
+    arrow_cast(2, 'UInt8'),
+    arrow_cast(2, 'UInt16'),
+    arrow_cast(2, 'UInt32'),
+    arrow_cast(2, 'UInt64'),
+    arrow_cast(2, 'Float32'),
+    arrow_cast(2, 'Float64')
+)
+;
+
+query R
+SELECT sqrt(column1) FROM t
+----
+1.4142135623730951
+
+query R
+SELECT SQRT(column1) FROM t
+----
+1.4142135623730951
+
+statement error Error during planning: Invalid function 'SQRT'
+SELECT "SQRT"(column1) FROM t
+
+query R
+SELECT "sqrt"(column1) FROM t
+----
+1.4142135623730951
+
+# case_builtin_math_expression
+query RRRRRRRRRR
+SELECT sqrt(column1),sqrt(column2),sqrt(column3),sqrt(column4),sqrt(column5),sqrt(column6),sqrt(column7),sqrt(column8),sqrt(column9),sqrt(column10) FROM t

Review Comment:
   This data could replace the original test case. Can you guys provide some feedback?
   
   https://github.com/apache/arrow-datafusion/blob/1a1efcf7261335f1d7814be9fbb2eb455aba7e54/datafusion/core/tests/sql/functions.rs#L78-L142
   
   



-- 
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] jiangzhx commented on a diff in pull request #6608: Port remaining tests in functions.rs to sqllogictest

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


##########
datafusion/core/tests/sqllogictests/test_files/functions.slt:
##########
@@ -479,4 +479,90 @@ SELECT struct(c1,c2,c3,c4,a,b) from simple_struct_test
 {c0: 1, c1: 1, c2: 3.1, c3: 3.14, c4: str, c5: text}
 
 statement ok
-drop table simple_struct_test
\ No newline at end of file
+drop table simple_struct_test
+
+# create aggregate_test_100 table for functions test
+statement ok
+CREATE EXTERNAL TABLE aggregate_test_100 (
+  c1  VARCHAR NOT NULL,
+  c2  TINYINT NOT NULL,
+  c3  SMALLINT NOT NULL,
+  c4  SMALLINT,
+  c5  INT,
+  c6  BIGINT NOT NULL,
+  c7  SMALLINT NOT NULL,
+  c8  INT NOT NULL,
+  c9  BIGINT UNSIGNED NOT NULL,
+  c10 VARCHAR NOT NULL,
+  c11 FLOAT NOT NULL,
+  c12 DOUBLE NOT NULL,
+  c13 VARCHAR NOT NULL
+)
+STORED AS CSV
+WITH HEADER ROW
+LOCATION '../../testing/data/csv/aggregate_test_100.csv'
+
+
+# sqrt_f32_vs_f64
+query R
+SELECT avg(sqrt(c11)) FROM aggregate_test_100
+----
+0.6584408485889435
+
+query R
+SELECT avg(CAST(sqrt(c11) AS double)) FROM aggregate_test_100
+----
+0.6584408485889435
+
+query R
+SELECT avg(sqrt(CAST(c11 AS double))) FROM aggregate_test_100
+----
+0.6584408483418833
+
+statement ok
+drop table aggregate_test_100
+
+
+# case_sensitive_identifiers_functions
+statement ok
+create table t as values (
+    arrow_cast(2, 'Int8'),
+    arrow_cast(2, 'Int16'),
+    arrow_cast(2, 'Int32'),
+    arrow_cast(2, 'Int64'),
+    arrow_cast(2, 'UInt8'),
+    arrow_cast(2, 'UInt16'),
+    arrow_cast(2, 'UInt32'),
+    arrow_cast(2, 'UInt64'),
+    arrow_cast(2, 'Float32'),
+    arrow_cast(2, 'Float64')
+)
+;
+
+query R
+SELECT sqrt(column1) FROM t
+----
+1.4142135623730951

Review Comment:
   The original test case had a value of `1`, but when I called `sqrt(1)` in SQLLogicTest, it returned a value of `1`, which should have been displayed as `1.0` for clarity. To make the response more reasonable, I changed the value in the test case from `1 `to `2`, it's will retrun `1.4142135623730951`



-- 
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 #6608: Port remaining tests in functions.rs to sqllogictest

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


##########
datafusion/core/tests/sqllogictests/test_files/functions.slt:
##########
@@ -479,4 +479,90 @@ SELECT struct(c1,c2,c3,c4,a,b) from simple_struct_test
 {c0: 1, c1: 1, c2: 3.1, c3: 3.14, c4: str, c5: text}
 
 statement ok
-drop table simple_struct_test
\ No newline at end of file
+drop table simple_struct_test
+
+# create aggregate_test_100 table for functions test
+statement ok
+CREATE EXTERNAL TABLE aggregate_test_100 (
+  c1  VARCHAR NOT NULL,
+  c2  TINYINT NOT NULL,
+  c3  SMALLINT NOT NULL,
+  c4  SMALLINT,
+  c5  INT,
+  c6  BIGINT NOT NULL,
+  c7  SMALLINT NOT NULL,
+  c8  INT NOT NULL,
+  c9  BIGINT UNSIGNED NOT NULL,
+  c10 VARCHAR NOT NULL,
+  c11 FLOAT NOT NULL,
+  c12 DOUBLE NOT NULL,
+  c13 VARCHAR NOT NULL
+)
+STORED AS CSV
+WITH HEADER ROW
+LOCATION '../../testing/data/csv/aggregate_test_100.csv'
+
+
+# sqrt_f32_vs_f64
+query R
+SELECT avg(sqrt(c11)) FROM aggregate_test_100
+----
+0.6584408485889435
+
+query R
+SELECT avg(CAST(sqrt(c11) AS double)) FROM aggregate_test_100
+----
+0.6584408485889435
+
+query R
+SELECT avg(sqrt(CAST(c11 AS double))) FROM aggregate_test_100
+----
+0.6584408483418833
+
+statement ok
+drop table aggregate_test_100
+
+
+# case_sensitive_identifiers_functions
+statement ok
+create table t as values (

Review Comment:
   I think using 2 is a better value than 1 👍 



-- 
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] jackwener closed pull request #6608: Port remaining tests in functions.rs to sqllogictest

Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener closed pull request #6608: Port remaining tests in functions.rs to sqllogictest
URL: https://github.com/apache/arrow-datafusion/pull/6608


-- 
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] jiangzhx commented on a diff in pull request #6608: Port remaining tests in functions.rs to sqllogictest

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


##########
datafusion/core/tests/sqllogictests/src/engines/conversion.rs:
##########
@@ -87,5 +87,5 @@ pub fn decimal_to_str(value: Decimal) -> String {
 }
 
 pub fn big_decimal_to_str(value: BigDecimal) -> String {
-    value.round(12).normalized().to_string()
+    value.round(16).normalized().to_string()

Review Comment:
   `Sqrt(2)` returns a double value of `1.4142135623730951`. 
   the precision of `value.round(12)` is not sufficient, `1.414213562373` is returned. 
   To improve accuracy, we could increase the rounding precision to `value.round(16)`



-- 
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] jiangzhx commented on a diff in pull request #6608: Port remaining tests in functions.rs to sqllogictest

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


##########
datafusion/core/tests/sqllogictests/src/engines/conversion.rs:
##########
@@ -87,5 +87,5 @@ pub fn decimal_to_str(value: Decimal) -> String {
 }
 
 pub fn big_decimal_to_str(value: BigDecimal) -> String {
-    value.round(12).normalized().to_string()
+    value.round(16).normalized().to_string()

Review Comment:
   will cause other testcase failed:
   
   - pg_compat_simple.slt:76
   - window.slt:441
   - decimal.slt:391
   - predicates.slt:47
   - pg_compat_window.slt:692
   
   so  i reverted change.



-- 
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] jiangzhx commented on a diff in pull request #6608: Port remaining tests in functions.rs to sqllogictest

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


##########
datafusion/core/tests/sqllogictests/src/engines/conversion.rs:
##########
@@ -87,5 +87,5 @@ pub fn decimal_to_str(value: Decimal) -> String {
 }
 
 pub fn big_decimal_to_str(value: BigDecimal) -> String {
-    value.round(12).normalized().to_string()
+    value.round(16).normalized().to_string()

Review Comment:
   will cause other testcase failed,so  i reverted change.



-- 
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] jackwener merged pull request #6608: Port remaining tests in functions.rs to sqllogictest

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


-- 
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] jackwener commented on pull request #6608: Port remaining tests in functions.rs to sqllogictest

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

   I clicked by mistake, sorry ...


-- 
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] jiangzhx commented on a diff in pull request #6608: Port remaining tests in functions.rs to sqllogictest

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


##########
datafusion/core/tests/sqllogictests/test_files/functions.slt:
##########
@@ -479,4 +479,90 @@ SELECT struct(c1,c2,c3,c4,a,b) from simple_struct_test
 {c0: 1, c1: 1, c2: 3.1, c3: 3.14, c4: str, c5: text}
 
 statement ok
-drop table simple_struct_test
\ No newline at end of file
+drop table simple_struct_test
+
+# create aggregate_test_100 table for functions test
+statement ok
+CREATE EXTERNAL TABLE aggregate_test_100 (
+  c1  VARCHAR NOT NULL,
+  c2  TINYINT NOT NULL,
+  c3  SMALLINT NOT NULL,
+  c4  SMALLINT,
+  c5  INT,
+  c6  BIGINT NOT NULL,
+  c7  SMALLINT NOT NULL,
+  c8  INT NOT NULL,
+  c9  BIGINT UNSIGNED NOT NULL,
+  c10 VARCHAR NOT NULL,
+  c11 FLOAT NOT NULL,
+  c12 DOUBLE NOT NULL,
+  c13 VARCHAR NOT NULL
+)
+STORED AS CSV
+WITH HEADER ROW
+LOCATION '../../testing/data/csv/aggregate_test_100.csv'
+
+
+# sqrt_f32_vs_f64
+query R
+SELECT avg(sqrt(c11)) FROM aggregate_test_100
+----
+0.6584408485889435
+
+query R
+SELECT avg(CAST(sqrt(c11) AS double)) FROM aggregate_test_100
+----
+0.6584408485889435
+
+query R
+SELECT avg(sqrt(CAST(c11 AS double))) FROM aggregate_test_100
+----
+0.6584408483418833
+
+statement ok
+drop table aggregate_test_100
+
+
+# case_sensitive_identifiers_functions
+statement ok
+create table t as values (

Review Comment:
   This data could replace the original test case. Can you guys provide some feedback?
   
   https://github.com/apache/arrow-datafusion/blob/1a1efcf7261335f1d7814be9fbb2eb455aba7e54/datafusion/core/tests/sql/functions.rs#L78-L142
   
   



-- 
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