Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port remaining tests in functions.rs to sqllogictest #6608

Merged
merged 1 commit into from
Jun 9, 2023

Conversation

jiangzhx
Copy link
Contributor

@jiangzhx jiangzhx commented Jun 9, 2023

Which issue does this PR close?

Closes #6300.

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) labels Jun 9, 2023
@jiangzhx jiangzhx changed the title move functions.rs to sqllogictests Port remaining tests in functions.rs to sqllogictest Jun 9, 2023
@jiangzhx jiangzhx marked this pull request as draft June 9, 2023 09:17
@@ -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()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Contributor Author

@jiangzhx jiangzhx Jun 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

SELECT sqrt(column1) FROM t
----
1.4142135623730951
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

# case_sensitive_identifiers_functions
statement ok
create table t as values (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using 2 is a better value than 1 👍

@jiangzhx jiangzhx marked this pull request as ready for review June 9, 2023 13:55
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks great -- thank you @jiangzhx

# case_sensitive_identifiers_functions
statement ok
create table t as values (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using 2 is a better value than 1 👍

Copy link
Member

@jackwener jackwener left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you @jiangzhx

@jackwener jackwener closed this Jun 9, 2023
@jackwener jackwener reopened this Jun 9, 2023
@jackwener
Copy link
Member

I clicked by mistake, sorry ...

@jackwener jackwener merged commit d9e91d1 into apache:main Jun 9, 2023
@jiangzhx jiangzhx deleted the issues/6300 branch June 12, 2023 02:24
jayzhan211 pushed a commit to jayzhan211/datafusion that referenced this pull request Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port remaining tests in functions.rs to sqllogictest
3 participants