mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-31 03:07:20 +00:00
add default value for window frame
This commit is contained in:
parent
e548d38de8
commit
950daf39bb
2 changed files with 25 additions and 1 deletions
|
@ -444,6 +444,19 @@ pub struct WindowFrame {
|
||||||
// TBD: EXCLUDE
|
// TBD: EXCLUDE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for WindowFrame {
|
||||||
|
/// returns default value for window frame
|
||||||
|
///
|
||||||
|
/// see https://www.sqlite.org/windowfunctions.html#frame_specifications
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
units: WindowFrameUnits::Range,
|
||||||
|
start_bound: WindowFrameBound::Preceding(None),
|
||||||
|
end_bound: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub enum WindowFrameUnits {
|
pub enum WindowFrameUnits {
|
||||||
|
@ -1622,3 +1635,14 @@ impl fmt::Display for SqliteOnConflict {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_window_frame_default() {
|
||||||
|
let window_frame = WindowFrame::default();
|
||||||
|
assert_eq!(WindowFrameBound::Preceding(None), window_frame.start_bound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ fn parse_insert_sqlite() {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
{
|
{
|
||||||
Statement::Insert { or, .. } => assert_eq!(or, expected_action),
|
Statement::Insert { or, .. } => assert_eq!(or, expected_action),
|
||||||
_ => panic!("{}", sql.to_string()),
|
_ => panic!("{}", sql),
|
||||||
};
|
};
|
||||||
|
|
||||||
let sql = "INSERT INTO test_table(id) VALUES(1)";
|
let sql = "INSERT INTO test_table(id) VALUES(1)";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue