fix: allow .(dot) literal in table name (#2483)

* fix: allow `.`(dot) literal in table name

* fix: resolve PR comments
This commit is contained in:
LFC
2023-09-27 19:50:07 +08:00
committed by GitHub
parent ee8d472aae
commit ccd6de8d6b
5 changed files with 22 additions and 36 deletions

View File

@@ -13,9 +13,6 @@
// limitations under the License.
use consts::DEFAULT_CATALOG_NAME;
use snafu::ensure;
use crate::error::Result;
pub mod consts;
pub mod error;
@@ -26,17 +23,6 @@ pub fn format_full_table_name(catalog: &str, schema: &str, table: &str) -> Strin
format!("{catalog}.{schema}.{table}")
}
pub fn parse_full_table_name(table_name: &str) -> Result<(&str, &str, &str)> {
let result = table_name.split('.').collect::<Vec<_>>();
ensure!(
result.len() == 3,
error::InvalidFullTableNameSnafu { table_name }
);
Ok((result[0], result[1], result[2]))
}
/// Build db name from catalog and schema string
pub fn build_db_string(catalog: &str, schema: &str) -> String {
if catalog == DEFAULT_CATALOG_NAME {

View File

@@ -80,7 +80,7 @@ use crate::DatanodeId;
pub const REMOVED_PREFIX: &str = "__removed";
const NAME_PATTERN: &str = "[a-zA-Z_:-][a-zA-Z0-9_:-]*";
const NAME_PATTERN: &str = r"[a-zA-Z_:-][a-zA-Z0-9_:\-\.]*";
const DATANODE_TABLE_KEY_PREFIX: &str = "__dn_table";
const TABLE_INFO_KEY_PREFIX: &str = "__table_info";

View File

@@ -268,6 +268,8 @@ mod tests {
test_ok("my_table");
test_ok("cpu:metrics");
test_ok(":cpu:metrics");
test_ok("sys.cpu.system");
test_ok("foo-bar");
}
#[test]