Skip to content

Commit a646bb4

Browse files
authored
refactor: remove databend-common-base from databend-common-ast (#15519)
1 parent d6eaadb commit a646bb4

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

src/query/ast/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ ignored = ["geos"]
1616

1717
[dependencies] # In alphabetical order
1818
# Workspace dependencies
19-
databend-common-base = { path = "../../common/base" }
2019
databend-common-exception = { path = "../../common/exception" }
2120
databend-common-io = { path = "../../common/io" }
2221

src/query/ast/src/ast/statements/copy.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use std::io::Error;
2020
use std::io::ErrorKind;
2121
use std::io::Result;
2222

23-
use databend_common_base::base::mask_string;
2423
use databend_common_exception::ErrorCode;
2524
use databend_common_io::escape_string_with_quote;
2625
use derive_visitor::Drive;
@@ -314,6 +313,17 @@ impl Display for Connection {
314313
}
315314
}
316315

316+
/// Mask a string by "******", but keep `unmask_len` of suffix.
317+
fn mask_string(s: &str, unmask_len: usize) -> String {
318+
if s.len() <= unmask_len {
319+
s.to_string()
320+
} else {
321+
let mut ret = "******".to_string();
322+
ret.push_str(&s[(s.len() - unmask_len)..]);
323+
ret
324+
}
325+
}
326+
317327
/// UriLocation (a.k.a external location) can be used in `INTO` or `FROM`.
318328
///
319329
/// For examples: `'s3://example/path/to/dir' CONNECTION = (AWS_ACCESS_ID="admin" AWS_SECRET_KEY="admin")`
@@ -400,16 +410,19 @@ impl UriLocation {
400410
connection: Connection::new(conns),
401411
})
402412
}
413+
414+
pub fn mask(&self) -> Self {
415+
Self {
416+
connection: self.connection.mask(),
417+
..self.clone()
418+
}
419+
}
403420
}
404421

405422
impl Display for UriLocation {
406423
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
407424
write!(f, "'{}://{}{}'", self.protocol, self.name, self.path)?;
408-
if f.alternate() {
409-
write!(f, "{}", self.connection.mask())?;
410-
} else {
411-
write!(f, "{}", self.connection)?;
412-
}
425+
write!(f, "{}", self.connection)?;
413426
if !self.part_prefix.is_empty() {
414427
write!(f, " LOCATION_PREFIX = '{}'", self.part_prefix)?;
415428
}

src/query/sql/src/planner/binder/ddl/table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ impl Binder {
697697
// keep a copy of table data uri_location, will be used in "show create table"
698698
options.insert(
699699
OPT_KEY_TABLE_ATTACHED_DATA_URI.to_string(),
700-
format!("{:#}", stmt.uri_location),
700+
format!("{}", stmt.uri_location.mask()),
701701
);
702702

703703
let mut uri = stmt.uri_location.clone();

src/query/sql/src/planner/semantic/type_check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3537,7 +3537,7 @@ impl<'a> TypeChecker<'a> {
35373537
.await
35383538
.map_err(|err| {
35393539
ErrorCode::SemanticError(format!(
3540-
"Failed to resolve WASM code location {:#?}: {}",
3540+
"Failed to resolve WASM code location {:?}: {}",
35413541
&udf_definition.code, err
35423542
))
35433543
})?;

0 commit comments

Comments
 (0)