Skip to content

Commit abf8bb6

Browse files
committed
chore(query): move insert format deser from binder into interpreter
1 parent 4ad4fc8 commit abf8bb6

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/query/service/src/interpreters/interpreter_insert_v2.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ impl Interpreter for InsertInterpreterV2 {
138138
match format.as_str() {
139139
"VALUES" => {
140140
let settings = self.ctx.get_settings();
141-
let name_resolution_ctx = NameResolutionContext::try_from(settings.as_ref())?;
141+
let name_resolution_ctx =
142+
NameResolutionContext::try_from(settings.as_ref())?;
142143
let inner = ValueSource::new(
143144
str.to_string(),
144145
self.ctx.clone(),
@@ -301,7 +302,7 @@ struct FormatSource {
301302
is_finished: bool,
302303
}
303304

304-
impl<'a> SyncSource for FormatSource {
305+
impl SyncSource for FormatSource {
305306
const NAME: &'static str = "FormatSource";
306307

307308
fn generate(&mut self) -> Result<Option<DataBlock>> {

src/query/service/src/sql/planner/binder/insert.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,12 @@ impl<'a> Binder {
8080

8181
let input_source: Result<InsertInputSource> = match source.clone() {
8282
InsertSource::Streaming { format, rest_str } => {
83-
self.analyze_stream_format( rest_str, Some(format))
84-
.await
83+
self.analyze_stream_format(rest_str, Some(format)).await
8584
}
8685
InsertSource::Values { rest_str, .. } => {
8786
let str = rest_str.trim_end_matches(';');
88-
self.analyze_stream_format(
89-
str,
90-
Some("VALUES".to_string()),
91-
)
92-
.await
87+
self.analyze_stream_format(str, Some("VALUES".to_string()))
88+
.await
9389
}
9490
InsertSource::Select { query } => {
9591
let statement = Statement::Query(query);
@@ -127,7 +123,7 @@ impl<'a> Binder {
127123
let data = stream_str.to_owned();
128124
Ok(InsertInputSource::StrWithFormat((
129125
data,
130-
format.unwrap_or("VALUES".to_string()),
126+
format.unwrap_or_else(|| "VALUES".to_string()),
131127
)))
132128
}
133129
}

0 commit comments

Comments
 (0)