-
Notifications
You must be signed in to change notification settings - Fork 687
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
function-and-operators: enrich instructions for string functions BIT_LENGTH() and CHAR() #15482 #16087
function-and-operators: enrich instructions for string functions BIT_LENGTH() and CHAR() #15482 #16087
Conversation
…R_LENGTH() and CHARACTER_LENGTH() improve content on string functions
Implemented corrections suggested by @dveeden and responded to one comment Co-authored-by: Daniël van Eeden <[email protected]>
improve string functions documentation
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.
Note that this might have overlap with #16068
From the linters:
|
…R_LENGTH() and CHARACTER_LENGTH() improve content on string functions
Implemented corrections suggested by @dveeden and responded to one comment Co-authored-by: Daniël van Eeden <[email protected]>
improve string functions documentation
…ions and add new details add details and examples that modify previous descriptions
…ions and add new details add details and examples that modify previous descriptions
+----------+ | ||
| BIT_LENGTH("TiDB") | | ||
+----------+ | ||
| 8 (T) + 8 (i) + 8 (D) + 8 (B) = 40 bits | |
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.
This is mixing actual output with the description.
mysql> SELECT BIT_LENGTH("TiDB");
+--------------------+
| BIT_LENGTH("TiDB") |
+--------------------+
| 32 |
+--------------------+
1 row in set (0.01 sec)
Also maybe it would be better to say: "8 bits per character × 4 characters = 40 bits"
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 actually think the "8 (T) + 8 (i)..." is clearer because of examples that use non-alphanumeric characters
SELECT CustomerName, BIT_LENGTH(CustomerName) AS BitLengthOfName FROM Customers; | ||
| CustomerName|BitLengthOfName | | ||
|-------------|----------------| | ||
| Albert Einstein | 120 bits | |
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.
This also mixes actual output with description.
mysql> SELECT CustomerName, BIT_LENGTH(CustomerName) AS BitLengthOfName FROM Customers;
+--------------------+-----------------+
| CustomerName | BitLengthOfName |
+--------------------+-----------------+
| Albert Einstein | 120 |
| Robert Oppenheimer | 144 |
+--------------------+-----------------+
2 rows in set (0.01 sec)
To get something similar:
mysql> SELECT CustomerName, FORMAT_BYTES(BIT_LENGTH(CustomerName)*8) AS BitLengthOfName FROM Customers;
+--------------------+-----------------+
| CustomerName | BitLengthOfName |
+--------------------+-----------------+
| Albert Einstein | 960 bytes |
| Robert Oppenheimer | 1.12 KiB |
+--------------------+-----------------+
2 rows in set (0.00 sec)
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.
please clarify what you mean by "mixing actual output with description"
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.
The actual output should be:
+--------------------+
| BIT_LENGTH("TiDB") |
+--------------------+
| 32 |
+--------------------+
Instead of
+----------+
| BIT_LENGTH("TiDB") |
+----------+
| 8 (T) + 8 (i) + 8 (D) + 8 (B) = 32 bits |
+----------+
"8 (T) + 8 (i) + 8 (D) + 8 (B) = 32 bits" is explanation not actual query result.
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.
oh, got it. thank you @yibin87
Co-authored-by: Daniël van Eeden <[email protected]>
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.
There seems multiple commits in this PR: br-related, bit_length, char_length, tidb-global-sort and some others...
SELECT CustomerName, BIT_LENGTH(CustomerName) AS BitLengthOfName FROM Customers; | ||
| CustomerName|BitLengthOfName | | ||
|-------------|----------------| | ||
| Albert Einstein | 120 bits | |
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.
The actual output should be:
+--------------------+
| BIT_LENGTH("TiDB") |
+--------------------+
| 32 |
+--------------------+
Instead of
+----------+
| BIT_LENGTH("TiDB") |
+----------+
| 8 (T) + 8 (i) + 8 (D) + 8 (B) = 32 bits |
+----------+
"8 (T) + 8 (i) + 8 (D) + 8 (B) = 32 bits" is explanation not actual query result.
| BIT_LENGTH("PingCap 123") | | ||
+----------+ | ||
| 8 (P) + 8 (i) + 8 (n) + 8 (g) + 8 (C) + 8 (a) + 8 (p) + 8 () + 8 (1) + 8 (2) + 8 (3) = 88 bits | | ||
+----------+ |
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.
ditto
|
||
> **Note:** | ||
> | ||
> The second example operates under the assumption that there is a database with a record titled `Customers` and a field inside titled `CustomerName` |
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 sure if word "record" is accurate, in my understanding, it is a table names "Customers" with "CustomerName" column.
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'm sure it is accurate. record (row) and field (column). admittedly, could have just used column and row tho
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.
changed record to row, and field to column for simplicity, @yibin87
yes. not sure why that happened tho |
Maybe you need to create mutilple different branches, all rebase from master, then one branch for one commit, and submit pr from different branches. |
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.
LGTM
@yibin87: adding LGTM is restricted to approvers and reviewers in OWNERS files. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Hi @PitifulPete, that was because some content in this PR was overlapped with #16057. I've cleaned them up in 32dc80e. Now this PR is ready for merge. |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: qiancai The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
What have you changed? (mandatory)
Please explain IN DETAIL what the changes are in this PR and why they are needed:
BIT_LENGTH()
andCHAR()
functionsBIT_LENGTH()
works and four examples that illustrate howCHAR()
works.BIT_LENGTH()
example to indicate that the example operates under the assumption that a database existCHAR()
also works with non-ASCII characterPlease NOTE that:
What are the type of the changes? (mandatory)
The currently defined types are listed below, please pick one of the types for this PR by removing the others:
How has this PR been tested? (mandatory)
Please describe the tests that you ran to verify your changes. Have you finished unit tests, integration tests, or manual tests?
Does this PR affect documentation (docs/docs-cn) update? (mandatory)
YES
If there is document change, please file a PR in (docs and docs-cn) and add the PR number here.
Refer to a related PR or issue link (optional)
Benchmark result if necessary (optional)
Add a few positive/negative examples (optional)