Skip to content

Commit

Permalink
fix(parser): cdc source cannot define columns and constraints (#16636)
Browse files Browse the repository at this point in the history
  • Loading branch information
StrikeW authored May 10, 2024
1 parent e5c9c48 commit 2dd6b73
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/sqlparser/src/ast/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,13 @@ impl ParseTo for CreateSourceStatement {
.iter()
.find(|&opt| opt.name.real_value() == UPSTREAM_SOURCE_KEY);
let connector: String = option.map(|opt| opt.value.to_string()).unwrap_or_default();
// The format of cdc source job is fixed to `FORMAT PLAIN ENCODE JSON`
let cdc_source_job =
connector.contains("-cdc") && columns.is_empty() && constraints.is_empty();
let cdc_source_job = connector.contains("-cdc");
if cdc_source_job && (!columns.is_empty() || !constraints.is_empty()) {
return Err(ParserError::ParserError(
"CDC source cannot define columns and constraints".to_string(),
));
}

// row format for nexmark source must be native
// default row format for datagen source is native
let source_schema = p.parse_source_schema_with_connector(&connector, cdc_source_job)?;
Expand Down

0 comments on commit 2dd6b73

Please sign in to comment.