Skip to content

Commit

Permalink
Fix transaction kind check
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Dec 4, 2024
1 parent 9b9df23 commit 8bf418d
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions datafusion/sql/src/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ use datafusion_expr::{
Volatility, WriteOp,
};
use sqlparser::ast::{
self, NullsDistinctOption, ShowStatementIn, ShowStatementOptions, SqliteOnConflict,
self, BeginTransactionKind, NullsDistinctOption, ShowStatementIn,
ShowStatementOptions, SqliteOnConflict,
};
use sqlparser::ast::{
Assignment, AssignmentTarget, ColumnDef, CreateIndex, CreateTable,
Expand Down Expand Up @@ -904,11 +905,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
"Transaction modifier not supported: {modifier}"
);
}
if let Some(transaction) = transaction {
return not_impl_err!(
"Transaction kind not supported: {transaction}"
);
}
self.validate_transaction_kind(transaction)?;
let isolation_level: ast::TransactionIsolationLevel = modes
.iter()
.filter_map(|m: &TransactionMode| match m {
Expand Down Expand Up @@ -1994,4 +1991,19 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
.get_table_source(tables_reference)
.is_ok()
}

fn validate_transaction_kind(
&self,
kind: Option<BeginTransactionKind>,
) -> Result<()> {
match kind {
// BEGIN
None => Ok(()),
// BEGIN TRANSACTION
Some(BeginTransactionKind::Transaction) => Ok(()),
Some(BeginTransactionKind::Work) => {
not_impl_err!("Transaction kind not supported: {kind:?}")
}
}
}
}

0 comments on commit 8bf418d

Please sign in to comment.