-
Notifications
You must be signed in to change notification settings - Fork 43
Fixes gh-2206 Behavior changes in SQL #2350
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I believe all of the problems mentioned in #2296 have been documented here. See 11 comments below. I also want to say that some changes will be changed again in the next release.
non-integer results. | ||
Example: ``5 / 2``, result = 2. | ||
|
||
``%`` modulus (arithmetic) | ||
Divide second number into first number according to standard arithmetic rules. | ||
Divide second numeric into first numeric according to standard arithmetic rules. | ||
The result is the remainder. | ||
Example: ``17 % 5``, result = 2. | ||
|
||
``<<`` shift left (arithmetic) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All operands must be positive INTEGER or UNSIGNED. And here the implicit cast is helpless. The same for all bit-wise operations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay for %. And for the bit-wise operations, I'm changing "unsigned" to "non-negative INTEGER or UNSIGNED".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For % INTEGER could be of any sign, for example:
tarantool> box.execute([[SELECT -123 % 4;]])
---
- metadata:
- name: COLUMN_1
type: integer
rows:
- [-3]
...
tarantool> box.execute([[SELECT 123 % -4;]])
---
- metadata:
- name: COLUMN_1
type: integer
rows:
- [3]
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I added Example: -123 % 4, result = -3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still see
The result is the remainder.
Starting with Tarantool version 2.10.1, operands must be positive INTEGER or UNSIGNED.
@pgulutzan is this PR complete and ready for translation? |
@NickVolynkin: This PR is not ready for translation. I think that my replies to @ImeevMA are probably adequate but will not consider the issues "resolved" until he says okay. I see that @igormunkin is also a reviewer now, and I will add you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixes I added 4 more comments, but I think 3 of them are not essential. The only comment that matters is the one about %
operands.
the result will be 3, | ||
because X'41' is the third byte in the byte sequence. | ||
|
||
Starting with Tarantool version 2.10, arguments with data type VARBINARY are illegal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, now I'm working on bringing back to the POSITION() an ability to work with VARBINARY. Though I'm not sure if it's worth mentioning this in the doc right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean: it is only illegal in 2.10 beta, but in earlier and later versions it is legal?
In that case, I think, it is like a temporary bug: it's better to not mention it at all,
So I suggest: I will go back to the text in
https://www.tarantool.io/en/doc/latest/reference/reference_sql/sql_statements_and_clauses/#position
Okay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Also, it is likely that USING CHARACTERS / USING OCTETS
will be added in 2.10, but I'll create an issue for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, we have agreed that I will go back to the text in
https://www.tarantool.io/en/doc/latest/reference/reference_sql/sql_statements_and_clauses/#position
So I will make this change in a separate commit.
See the description of NoSQL type :ref:`'number' <index-box_number>`. | ||
Support for arithmetic and built-in functions with NUMBERs was removed in Tarantool version 2.10.1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we mention, that this is about "arithmetic" built-in functions? Some functions, such as typeof(), max(), least() and so on can work with NUMBERs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I changed to built-in arithmetic functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but I can't see where this was changed.
non-integer results. | ||
Example: ``5 / 2``, result = 2. | ||
|
||
``%`` modulus (arithmetic) | ||
Divide second number into first number according to standard arithmetic rules. | ||
Divide second numeric into first numeric according to standard arithmetic rules. | ||
The result is the remainder. | ||
Example: ``17 % 5``, result = 2. | ||
|
||
``<<`` shift left (arithmetic) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For % INTEGER could be of any sign, for example:
tarantool> box.execute([[SELECT -123 % 4;]])
---
- metadata:
- name: COLUMN_1
type: integer
rows:
- [-3]
...
tarantool> box.execute([[SELECT 123 % -4;]])
---
- metadata:
- name: COLUMN_1
type: integer
rows:
- [3]
...
@ImeevMA: Okay, I did a new commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! Thanks for fixes! I can still see that 2 of my previous comments have not been fixed. Perhaps I am looking at the wrong version? I added one more non-essential comment to the content added in the previous commit. Sorry that I did not added it before. Also, it looks like I have no permission to resolve our conversations, so should I write something like “Resolved”?
* When possible data types are any other scalar data type, SCALAR is default. |br| | ||
Example: ``box.execute([[SELECT TYPEOF(GREATEST(?,5);]]),{x})`` is 'scalar'. |br| | ||
* Otherwise, there is no default. |br| | ||
Example: ``box.execute([[SELECT TYPEOF(LIKELY(?);]]),{x})`` is unknown. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I am overthinking, but to me the "unknown" sounds a little strange here. Maybe it's better to replace it with "the name of one of the primitive data types"?
See the description of NoSQL type :ref:`'number' <index-box_number>`. | ||
Support for arithmetic and built-in functions with NUMBERs was removed in Tarantool version 2.10.1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but I can't see where this was changed.
non-integer results. | ||
Example: ``5 / 2``, result = 2. | ||
|
||
``%`` modulus (arithmetic) | ||
Divide second number into first number according to standard arithmetic rules. | ||
Divide second numeric into first numeric according to standard arithmetic rules. | ||
The result is the remainder. | ||
Example: ``17 % 5``, result = 2. | ||
|
||
``<<`` shift left (arithmetic) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still see
The result is the remainder.
Starting with Tarantool version 2.10.1, operands must be positive INTEGER or UNSIGNED.
@igormunkin: You self-requested a review two months ago. Are you still interested? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pgulutzan, sorry for such delay: PR has been sunk in GitHub notifications traffic. The changes LGTM, except a couple of tiny nits. Thanks a lot!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @pgulutzan,
During the translation I encountered a few punctuation moments, as well as a couple of other suggestions, I would be happy if you could take a look at them
@@ -214,7 +214,7 @@ A literal has :ref:`data type = VARBINARY <sql_data_type_varbinary>` | |||
|
|||
Here are four ways to put non-ASCII characters,such as the Greek letter α alpha, in string literals: |br| | |||
First make sure that your shell program is set to accept characters as UTF-8. A simple way to check is |br| | |||
``SELECT hex('α');`` | |||
``SELECT hex(cast('α' as VARBINARY));`` | |||
If the result is CEB1 -- which is the hexadecimal value for the UTF-8 representation of α -- it is good. |br| | |||
(1) Simply enclose the character inside ``'...'``, |br| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pgulutzan, this looks like a list, should we maybe format it like one? I mean, in ReStructuredText formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That might be a good idea, but I think it should be considered for a different pull request. As you might have noticed, there are now some more data types, so after this is merged I will probably need to make a new pull request for "Even more behavior changes in SQL".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patiencedaur should we make a task out of it and put it in backlog for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexandra-mara Yes please. Can you create an issue so we don't forget about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patiencedaur: In the pull request #2523 you will see that I formatted the list with bullets.
in effect use TYPEOF(item) not the defined data type. | ||
from VARBINARY to a numeric, which is not sensible. | ||
#. The result data type of a primitive combination is sometimes SCALAR although we | ||
in effect use the primitive data type not the defined data type. | ||
(Here we use the word "combination" in the way that the standard document |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @pgulutzan,
Is this the standard document you are talking about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not exactly, that's the technical corrigendum i.e. the list of corrections for SQL:2011. We care about SQL:2016 as mentioned earlier in the manual, and we care about the actual document not a corrigendum. However, there wasn't significant change between 2011 and 2016 for this or indeed for most of the features that Tarantool tries to support, so we can just say "standard document".
for example ``'7' + '7'`` = 14. | ||
And for comparison, ``'7'`` = 7. | ||
This is called implicit casting. It is applicable for STRINGs and all numeric data types. | ||
This is called implicit casting. It was applicable for STRINGs and all numeric data types. | ||
Starting with Tarantool version 2.10, it is no longer supported. | ||
|
||
Limitations: (`Issue#2346 <https://github.com/tarantool/tarantool/issues/2346>`_) |br| | ||
* Some words, for example MATCH and REGEXP, are reserved but are not necessary for current or planned Tarantool versions |br| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By "MATCH and REGEXP are not necessary", do you mean that they can be easily replaced by other words? Can these words be used or do they cause an exception? Please clarify the "necessity" concept.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these words are reserved, they cannot be used except within quote marks, so yes their use would cause an error. Although it is a good idea to reserve a word if it is going to be used in a future Tarantool version, that is not the case here, or at least it wasn't the case when I wrote that and I know of no plan now. By the way, there are a few words that will be added to the reserved list soon.
To represent "Inf" (infinity), write a real numeric outside the double-precision numeric range, for example 1E309. | ||
To represent "nan" (not a number), write an expression that does not result in a real numeric, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pgulutzan By "real numeric", do you mean a number belonging to this mathematical set? That is, to represent "nan", you have to enter square root of minus one, for example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True enough, although since we're talking about a restriction of the set, I prefer to think of the Wikipedia article about https://en.wikipedia.org/wiki/NaN. As described earlier, we avoid the English word "number" now except for the 'number' type, but perhaps in Russian translation there would be no such problem. Is this preventing you from approving the pull request? ~~~~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but this was preventing me from finishing the translation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What made the matter more necessary now was that the NUMBER data type no longer had the typical characteristics that one associates with numbers. So in the initial comment I said
"
We will say "numeric" rather than "number" in some places. It's clumsy, but otherwise people will associate "number" with "NUMBER".
The alternative is to say, repeatedly, "number (but not NUMBER)".
"
Since no reviewer objected, I think it's considered okay.
@ImeevMA: I am suggesting you as a reviewer, but if you think it is more appropriate for other people it can be changed to whatever you think is reasonable. Since it is a large set of changes, it might be proper to have more than one dev reviewer. Since it is for 2.10 and the "release" page is not officially done yet, there is no rush. (That is why I have not yet added @NickVolynkin as a reviewer, but it will happen someday.) Of course this is related to issue #2296.
Some new comments:
We will say "numeric" rather than "number" in some places. It's clumsy, but otherwise people will associate "number" with "NUMBER".
The alternative is to say, repeatedly, "number (but not NUMBER)".
I made a mistake saying "always round down". I see now that rounding is toward zero.
In reference_sql/sql_features.rst: I decided to make no change. Although version 2.10 is a backward step with less standard compatibility than before, the examples for E011-04 and E011-06 still work. I noticed by chance that ALTER TABLE ... ADD COLUMN has been working for a while, so I changed that.
Some more new comments: regarding fourth commit:
Default function parameter types are at the end of SQL Statements and Clauses.
There are replies for all comments, although a few haven't been marked yet as resolved.
Resolves #2295, #2296, #2298