Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7539 from sundy-li/fv2-string
feat(query): add char/ord/soundex to function-v2
- Loading branch information
Showing
10 changed files
with
515 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ mod boolean; | |
mod control; | ||
mod datetime; | ||
mod math; | ||
mod soundex; | ||
mod string; | ||
mod string_multi_args; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2021 Datafuse Labs. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
pub(crate) struct Soundex; | ||
|
||
impl Soundex { | ||
#[inline(always)] | ||
pub fn number_map(i: char) -> Option<u8> { | ||
match i.to_ascii_lowercase() { | ||
'b' | 'f' | 'p' | 'v' => Some(b'1'), | ||
'c' | 'g' | 'j' | 'k' | 'q' | 's' | 'x' | 'z' => Some(b'2'), | ||
'd' | 't' => Some(b'3'), | ||
'l' => Some(b'4'), | ||
'm' | 'n' => Some(b'5'), | ||
'r' => Some(b'6'), | ||
_ => Some(b'0'), | ||
} | ||
} | ||
|
||
#[inline(always)] | ||
pub fn is_drop(c: char) -> bool { | ||
matches!( | ||
c.to_ascii_lowercase(), | ||
'a' | 'e' | 'i' | 'o' | 'u' | 'y' | 'h' | 'w' | ||
) | ||
} | ||
|
||
// https://github.com/mysql/mysql-server/blob/3290a66c89eb1625a7058e0ef732432b6952b435/sql/item_strfunc.cc#L1919 | ||
#[inline(always)] | ||
pub fn is_uni_alphabetic(c: char) -> bool { | ||
('a'..='z').contains(&c) || ('A'..='Z').contains(&c) || c as i32 >= 0xC0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
8202fed
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.
Successfully deployed to the following URLs:
databend – ./
databend-databend.vercel.app
databend-git-main-databend.vercel.app
databend.vercel.app
databend.rs