mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-12-04 03:31:39 +00:00
cargo fmt
This commit is contained in:
parent
dc97d8ef5d
commit
7bea9a8648
4 changed files with 7 additions and 17 deletions
|
|
@ -3,13 +3,12 @@ extern crate sqlparser;
|
||||||
use sqlparser::sqlparser::*;
|
use sqlparser::sqlparser::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
||||||
let sql = "SELECT a, b, 123, myfunc(b) \
|
let sql = "SELECT a, b, 123, myfunc(b) \
|
||||||
FROM table_1 \
|
FROM table_1 \
|
||||||
WHERE a > b AND b < 100 \
|
WHERE a > b AND b < 100 \
|
||||||
ORDER BY a DESC, b";
|
ORDER BY a DESC, b";
|
||||||
|
|
||||||
let ast = Parser::parse_sql(sql.to_string()).unwrap();
|
let ast = Parser::parse_sql(sql.to_string()).unwrap();
|
||||||
|
|
||||||
println!("AST: {:?}", ast);
|
println!("AST: {:?}", ast);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,6 @@ pub enum SQLType {
|
||||||
Time,
|
Time,
|
||||||
/// Timestamp
|
/// Timestamp
|
||||||
Timestamp,
|
Timestamp,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SQL Operator
|
/// SQL Operator
|
||||||
|
|
|
||||||
|
|
@ -309,7 +309,6 @@ impl Parser {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO: this function is inconsistent and sometimes returns bool and sometimes fails
|
//TODO: this function is inconsistent and sometimes returns bool and sometimes fails
|
||||||
|
|
||||||
/// Consume the next token if it matches the expected token, otherwise return an error
|
/// Consume the next token if it matches the expected token, otherwise return an error
|
||||||
|
|
@ -383,10 +382,7 @@ impl Parser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(ASTNode::SQLCreateTable {
|
Ok(ASTNode::SQLCreateTable { name: id, columns })
|
||||||
name: id,
|
|
||||||
columns,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
_ => parser_err!(format!(
|
_ => parser_err!(format!(
|
||||||
"Unexpected token after CREATE EXTERNAL TABLE: {:?}",
|
"Unexpected token after CREATE EXTERNAL TABLE: {:?}",
|
||||||
|
|
@ -802,10 +798,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
let ast = parse_sql(&sql);
|
let ast = parse_sql(&sql);
|
||||||
match ast {
|
match ast {
|
||||||
ASTNode::SQLCreateTable {
|
ASTNode::SQLCreateTable { name, columns } => {
|
||||||
name,
|
|
||||||
columns,
|
|
||||||
} => {
|
|
||||||
assert_eq!("uk_cities", name);
|
assert_eq!("uk_cities", name);
|
||||||
assert_eq!(3, columns.len());
|
assert_eq!(3, columns.len());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -166,8 +166,7 @@ impl Tokenizer {
|
||||||
.filter(|t| match t {
|
.filter(|t| match t {
|
||||||
Token::Whitespace => false,
|
Token::Whitespace => false,
|
||||||
_ => true,
|
_ => true,
|
||||||
})
|
}).collect())
|
||||||
.collect())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the next token or return None
|
/// Get the next token or return None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue