MCPcopy Create free account
hub / github.com/apache/datafusion / validate_input

Method validate_input

datafusion-cli/src/helper.rs:76–110  ·  view source on GitHub ↗
(&self, input: &str)

Source from the content-addressed store, hash-verified

74 }
75
76 fn validate_input(&self, input: &str) -> Result<ValidationResult> {
77 if let Some(sql) = input.strip_suffix(';') {
78 let dialect = match dialect_from_str(self.dialect) {
79 Some(dialect) => dialect,
80 None => {
81 return Ok(ValidationResult::Invalid(Some(format!(
82 " 🤔 Invalid dialect: {}",
83 self.dialect
84 ))));
85 }
86 };
87 let lines = split_from_semicolon(sql);
88 for line in lines {
89 match DFParser::parse_sql_with_dialect(&line, dialect.as_ref()) {
90 Ok(statements) if statements.is_empty() => {
91 return Ok(ValidationResult::Invalid(Some(
92 " 🤔 You entered an empty statement".to_string(),
93 )));
94 }
95 Ok(_statements) => {}
96 Err(err) => {
97 return Ok(ValidationResult::Invalid(Some(format!(
98 " 🤔 Invalid statement: {err}",
99 ))));
100 }
101 }
102 }
103 Ok(ValidationResult::Valid(None))
104 } else if input.starts_with('\\') {
105 // command
106 Ok(ValidationResult::Valid(None))
107 } else {
108 Ok(ValidationResult::Incomplete)
109 }
110 }
111}
112
113impl Default for CliHelper {

Callers 2

validateMethod · 0.80
readline_directFunction · 0.80

Calls 4

split_from_semicolonFunction · 0.85
as_refMethod · 0.45
is_emptyMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected