Skip to content

Commit e9a62b4

Browse files
waynexiakillme2008MichaelScofield
committed
Apply suggestions from code review
Co-authored-by: dennis zhuang <killme2008@gmail.com> Co-authored-by: LFC <990479+MichaelScofield@users.noreply.github.com> Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
1 parent e1d1c43 commit e9a62b4

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/operator/src/statement/comment.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ use crate::error::{ExecuteDdlSnafu, ExternalSnafu, InvalidSqlSnafu, Result};
2727
use crate::statement::StatementExecutor;
2828

2929
impl StatementExecutor {
30+
/// Adds a comment to a database object (table, column, or flow).
31+
///
32+
/// # Arguments
33+
///
34+
/// * `stmt`: A `Comment` struct containing the object to comment on and the comment text.
35+
/// * `query_ctx`: A `QueryContextRef` providing contextual information for the query.
36+
///
37+
/// # Returns
38+
///
39+
/// A `Result` containing the `Output` of the operation, or an error if the operation fails.
3040
pub async fn comment(&self, stmt: Comment, query_ctx: QueryContextRef) -> Result<Output> {
3141
let comment_on_task = self.create_comment_on_task_from_stmt(stmt, &query_ctx)?;
3242

src/sql/src/parsers/comment_parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl ParserContext<'_> {
3434
let target_token = self.parser.next_token();
3535
let comment = match target_token.token {
3636
Token::Word(word) if word.keyword == Keyword::TABLE => {
37-
let raw_table = self.parse_object_name().context(error::UnexpectedSnafu {
37+
let raw_table = self.parse_object_name().with_context(|_| error::UnexpectedSnafu {
3838
expected: "a table name",
3939
actual: self.peek_token_as_string(),
4040
})?;
@@ -47,7 +47,7 @@ impl ParserContext<'_> {
4747
Token::Word(word)
4848
if word.keyword == Keyword::NoKeyword && word.value.eq_ignore_ascii_case(FLOW) =>
4949
{
50-
let raw_flow = self.parse_object_name().context(error::UnexpectedSnafu {
50+
let raw_flow = self.parse_object_name().with_context(|_| error::UnexpectedSnafu {
5151
expected: "a flow name",
5252
actual: self.peek_token_as_string(),
5353
})?;
@@ -78,7 +78,7 @@ impl ParserContext<'_> {
7878
}
7979

8080
fn parse_column_comment_target(&mut self) -> Result<CommentObject> {
81-
let raw = self.parse_object_name().context(error::UnexpectedSnafu {
81+
let raw = self.parse_object_name().with_context(|_| error::UnexpectedSnafu {
8282
expected: "a column reference",
8383
actual: self.peek_token_as_string(),
8484
})?;

0 commit comments

Comments
 (0)