Skip to content

Commit 8bf418d

Browse files
committed
Fix transaction kind check
1 parent 9b9df23 commit 8bf418d

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

datafusion/sql/src/statement.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ use datafusion_expr::{
5555
Volatility, WriteOp,
5656
};
5757
use sqlparser::ast::{
58-
self, NullsDistinctOption, ShowStatementIn, ShowStatementOptions, SqliteOnConflict,
58+
self, BeginTransactionKind, NullsDistinctOption, ShowStatementIn,
59+
ShowStatementOptions, SqliteOnConflict,
5960
};
6061
use sqlparser::ast::{
6162
Assignment, AssignmentTarget, ColumnDef, CreateIndex, CreateTable,
@@ -904,11 +905,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
904905
"Transaction modifier not supported: {modifier}"
905906
);
906907
}
907-
if let Some(transaction) = transaction {
908-
return not_impl_err!(
909-
"Transaction kind not supported: {transaction}"
910-
);
911-
}
908+
self.validate_transaction_kind(transaction)?;
912909
let isolation_level: ast::TransactionIsolationLevel = modes
913910
.iter()
914911
.filter_map(|m: &TransactionMode| match m {
@@ -1994,4 +1991,19 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
19941991
.get_table_source(tables_reference)
19951992
.is_ok()
19961993
}
1994+
1995+
fn validate_transaction_kind(
1996+
&self,
1997+
kind: Option<BeginTransactionKind>,
1998+
) -> Result<()> {
1999+
match kind {
2000+
// BEGIN
2001+
None => Ok(()),
2002+
// BEGIN TRANSACTION
2003+
Some(BeginTransactionKind::Transaction) => Ok(()),
2004+
Some(BeginTransactionKind::Work) => {
2005+
not_impl_err!("Transaction kind not supported: {kind:?}")
2006+
}
2007+
}
2008+
}
19972009
}

0 commit comments

Comments
 (0)