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

builtin: logic op not compatibility with float #11587

Closed
wants to merge 3 commits into from

Conversation

jingyugao
Copy link
Contributor

Signed-off-by: jingyugao [email protected]

What problem does this PR solve?

#11552
logic operate not compatibility with float.

What is changed and how it works?

Make logic op cast args to real instead of int.
convert 0.1 to int will be 0, "0 or null" is null.
convert 0.1 to float will be 0.1, "0.1 or null" is 1.

Check List

Tests

  • Unit test
    add unit test

Code changes
changed in function body

Side effects
no
Related changes
no

@sre-bot
Copy link
Contributor

sre-bot commented Aug 2, 2019

Hi contributor, thanks for your PR.

This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically.

@sre-bot sre-bot added the contribution This PR is from a community contributor. label Aug 2, 2019
@CLAassistant
Copy link

CLAassistant commented Aug 2, 2019

CLA assistant check
All committers have signed the CLA.

@jingyugao
Copy link
Contributor Author

According to my test,mysql will convert args of logic operato to float64.(not read the mysql source code)
For example:
select '1e-323' or nul; // 1
select '1e-324' or null // NULL

convert '1e-324' to float64 is 0. "0 or null" is null.

@jingyugao jingyugao force-pushed the issue#11552 branch 2 times, most recently from 6ae55c6 to 9b34b0f Compare August 3, 2019 02:00
@codecov
Copy link

codecov bot commented Aug 3, 2019

Codecov Report

Merging #11587 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #11587   +/-   ##
===========================================
  Coverage   81.4299%   81.4299%           
===========================================
  Files           452        452           
  Lines         97194      97194           
===========================================
  Hits          79145      79145           
  Misses        12394      12394           
  Partials       5655       5655

@zz-jason zz-jason requested review from XuHuaiyu and qw4990 and removed request for XuHuaiyu August 4, 2019 07:13
@zz-jason zz-jason added the type/bugfix This PR fixes a bug. label Aug 4, 2019
@qw4990
Copy link
Contributor

qw4990 commented Aug 5, 2019

@jingyugao Thanks for your contribution, and we will review this PR soon.

expression/builtin_op.go Outdated Show resolved Hide resolved
@XuHuaiyu XuHuaiyu changed the title builtin: logic op not compatibility with float (#11552) builtin: logic op not compatibility with float Aug 5, 2019
@XuHuaiyu XuHuaiyu removed their request for review August 5, 2019 09:41
@jingyugao
Copy link
Contributor Author

gsed  -i 's/func (\(.\) \*\(.*\)) evalInt/func (\1 \*\2) evalReal(row chunk.Row) (float64, bool, error) { \narg, isNull, err := \1.evalInt(row) \nreturn float64(arg), isNull, err \n}\n\n func (\1 \*\2) evalInt/' expression/*.go

At last I use sed to add evalReal method for builtin*, it seems not bad.
Maybe evalBool is better than evalReal,but it seems not easy to hand.

@jingyugao
Copy link
Contributor Author

By the way, this change fix a bug about unary not.

select not 0.1 // 0 in mysql
select not 0.1 // 1 in tidb befroe

because tidb convert 0.1 to 0.

@zz-jason
Copy link
Member

@jingyugao Could you merge the master branch and resolve conflicts?

@zz-jason zz-jason requested review from qw4990 and SunRunAway August 25, 2019 08:41
@@ -37,8 +37,10 @@ var (
)

var (
_ builtinFunc = &builtinLogicAndSig{}
_ builtinFunc = &builtinLogicOrSig{}
_ builtinFunc = &builtinIntLogicAndSig{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have to remove ast.And and ast.Or from canFuncBePushed since the implementation of these two functions are not consistent with TiKV now?
What's your opinion @XuHuaiyu

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I refer to this pr, #10498 . ShouId keep the builtinLogicAndSig signature compatible to tiKV?

@SunRunAway SunRunAway removed their request for review September 11, 2019 09:00
@qw4990
Copy link
Contributor

qw4990 commented Nov 1, 2019

@jingyugao Sorry for my late reply, this issue seems fixed by this PR/12173.

@jingyugao
Copy link
Contributor Author

@jingyugao Sorry for my late reply, this issue seems fixed by this PR/12173.

sorry, too. busy these days.
Wish commit into TiDB next year.

@jingyugao jingyugao closed this Nov 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression contribution This PR is from a community contributor. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants