Skip to content

Commit d383de5

Browse files
committed
Update tests to use structured statement handling and document deprecated methods
✅ **Updated Tests to Use Structured AST:** - All timeout tests now use try_handle_structured_statement() - Tests demonstrate proper SqlStatement AST usage - Removed dependency on fragile string-based parsing in tests 📝 **Why Deprecated Methods Remain:** - **Internal use only** - These are private methods, not public API - **Test compatibility** - Some existing tests still reference them - **Gradual migration** - Can be fully removed in future cleanup - **No downstream impact** - External users never had access to these methods ✅ **Main Execution Paths Clean:** - Simple Query Handler: ✅ Uses structured AST - Extended Query Handler: ✅ Uses structured AST - Parser Shortcuts: ✅ Uses structured AST - Tests: ✅ Updated to use structured AST **Result: All production code paths now use robust structured statement parsing. Deprecated methods are internal implementation details with no external API impact.**
1 parent 3fee857 commit d383de5

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

datafusion-postgres/src/handlers.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,9 +1081,11 @@ mod tests {
10811081
let service = DfSessionService::new(session_context, auth_manager);
10821082
let mut client = MockClient::new();
10831083

1084-
// Test setting timeout to 5000ms
1084+
// Test setting timeout using structured AST parsing
1085+
use crate::sql::parse;
1086+
let set_statements = parse("SET statement_timeout = '5000ms'").unwrap();
10851087
let set_response = service
1086-
.try_respond_set_statements(&mut client, "set statement_timeout '5000ms'")
1088+
.try_handle_structured_statement(&mut client, &set_statements[0])
10871089
.await
10881090
.unwrap();
10891091
assert!(set_response.is_some());
@@ -1092,9 +1094,10 @@ mod tests {
10921094
let timeout = DfSessionService::get_statement_timeout(&client);
10931095
assert_eq!(timeout, Some(Duration::from_millis(5000)));
10941096

1095-
// Test SHOW statement_timeout
1097+
// Test SHOW statement_timeout using structured AST parsing
1098+
let show_statements = parse("SHOW statement_timeout").unwrap();
10961099
let show_response = service
1097-
.try_respond_show_statements(&client, "show statement_timeout")
1100+
.try_handle_structured_statement(&mut client, &show_statements[0])
10981101
.await
10991102
.unwrap();
11001103
assert!(show_response.is_some());
@@ -1107,15 +1110,18 @@ mod tests {
11071110
let service = DfSessionService::new(session_context, auth_manager);
11081111
let mut client = MockClient::new();
11091112

1110-
// Set timeout first
1113+
// Set timeout first using structured AST
1114+
use crate::sql::parse;
1115+
let set_statements = parse("SET statement_timeout = '1000ms'").unwrap();
11111116
service
1112-
.try_respond_set_statements(&mut client, "set statement_timeout '1000ms'")
1117+
.try_handle_structured_statement(&mut client, &set_statements[0])
11131118
.await
11141119
.unwrap();
11151120

1116-
// Disable timeout with 0
1121+
// Disable timeout with 0 using structured AST
1122+
let disable_statements = parse("SET statement_timeout = '0'").unwrap();
11171123
service
1118-
.try_respond_set_statements(&mut client, "set statement_timeout '0'")
1124+
.try_handle_structured_statement(&mut client, &disable_statements[0])
11191125
.await
11201126
.unwrap();
11211127

0 commit comments

Comments
 (0)