mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-12-23 11:12:51 +00:00
Add support for TABLESAMPLE pipe operator (#1860)
This commit is contained in:
parent
eacf00d269
commit
a8bde39efb
3 changed files with 29 additions and 5 deletions
|
|
@ -11054,6 +11054,7 @@ impl<'a> Parser<'a> {
|
|||
Keyword::LIMIT,
|
||||
Keyword::AGGREGATE,
|
||||
Keyword::ORDER,
|
||||
Keyword::TABLESAMPLE,
|
||||
])?;
|
||||
match kw {
|
||||
Keyword::SELECT => {
|
||||
|
|
@ -11116,6 +11117,10 @@ impl<'a> Parser<'a> {
|
|||
let exprs = self.parse_comma_separated(Parser::parse_order_by_expr)?;
|
||||
pipe_operators.push(PipeOperator::OrderBy { exprs })
|
||||
}
|
||||
Keyword::TABLESAMPLE => {
|
||||
let sample = self.parse_table_sample(TableSampleModifier::TableSample)?;
|
||||
pipe_operators.push(PipeOperator::TableSample { sample });
|
||||
}
|
||||
unhandled => {
|
||||
return Err(ParserError::ParserError(format!(
|
||||
"`expect_one_of_keywords` further up allowed unhandled keyword: {unhandled:?}"
|
||||
|
|
@ -12760,7 +12765,13 @@ impl<'a> Parser<'a> {
|
|||
} else {
|
||||
return Ok(None);
|
||||
};
|
||||
self.parse_table_sample(modifier).map(Some)
|
||||
}
|
||||
|
||||
fn parse_table_sample(
|
||||
&mut self,
|
||||
modifier: TableSampleModifier,
|
||||
) -> Result<Box<TableSample>, ParserError> {
|
||||
let name = match self.parse_one_of_keywords(&[
|
||||
Keyword::BERNOULLI,
|
||||
Keyword::ROW,
|
||||
|
|
@ -12842,14 +12853,14 @@ impl<'a> Parser<'a> {
|
|||
None
|
||||
};
|
||||
|
||||
Ok(Some(Box::new(TableSample {
|
||||
Ok(Box::new(TableSample {
|
||||
modifier,
|
||||
name,
|
||||
quantity,
|
||||
seed,
|
||||
bucket,
|
||||
offset,
|
||||
})))
|
||||
}))
|
||||
}
|
||||
|
||||
fn parse_table_sample_seed(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue