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

Implement uint64 logic into eval #8884

Merged
merged 3 commits into from
Sep 28, 2017
Merged

Implement uint64 logic into eval #8884

merged 3 commits into from
Sep 28, 2017

Conversation

jsternberg
Copy link
Contributor

@jsternberg jsternberg commented Sep 27, 2017

Any operation between an int64 and uint64 results in the type becoming a
uint64. This is because the most common will usually be an unsigned cursor
being modified by an int literal. Even in cases where we were to add an
unsigned literal to an integer iterator, that would just result in it being
recast back and overflow.

Includes a minor fix for dividing an integer by zero (should have resulted in
an integer, but resulted in a float) and I forgot to include UnsignedLiteral in
the logic for EvalType.

  • Rebased/mergable
  • Tests pass

influxql/ast.go Outdated
@@ -3988,7 +3988,7 @@ func evalBinaryExpr(expr *BinaryExpr, m map[string]interface{}) interface{} {
if !ok {
return nil
} else if rhs == 0 {
return float64(0)
return int64(0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

So this is a lot more confusing than I thought it would be. We appear to have an inconsistency. If you do division of two integers in a condition, you get integer division. I verified that the division below is between two integers. But, if you do division between two integers in a field (binary math), you get float division and will get a float (which EvalType doesn't return correctly and so would screw up subqueries).

I think we need to straighten out this behavior and backport that specific section to the 1.3 series.

CC @rbetts

Any operation between an int64 and uint64 results in the type becoming a
uint64. This is because the most common will usually be an unsigned
cursor being modified by an int literal. Even in cases where we were to
add an unsigned literal to an integer iterator, that would just result
in it being recast back and overflow.
@jsternberg jsternberg merged commit f0acb98 into master Sep 28, 2017
@ghost ghost removed the review label Sep 28, 2017
@jsternberg jsternberg deleted the js-uint-eval branch September 28, 2017 15:26
@jsternberg jsternberg mentioned this pull request Oct 5, 2017
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants