Skip to content

Commit c2d713f

Browse files
committed
Fix formatting of tablesample
1 parent ed4cf2f commit c2d713f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/ast/query.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,7 +1559,7 @@ impl fmt::Display for TableSampleBucket {
15591559
}
15601560
impl fmt::Display for TableSample {
15611561
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1562-
write!(f, " {}", self.modifier)?;
1562+
write!(f, "{}", self.modifier)?;
15631563
if let Some(name) = &self.name {
15641564
write!(f, " {}", name)?;
15651565
}
@@ -1862,7 +1862,7 @@ impl fmt::Display for TableFactor {
18621862
write!(f, " WITH ORDINALITY")?;
18631863
}
18641864
if let Some(TableSampleKind::BeforeTableAlias(sample)) = sample {
1865-
write!(f, "{sample}")?;
1865+
write!(f, " {sample}")?;
18661866
}
18671867
if let Some(alias) = alias {
18681868
write!(f, " AS {alias}")?;
@@ -1877,7 +1877,7 @@ impl fmt::Display for TableFactor {
18771877
write!(f, "{version}")?;
18781878
}
18791879
if let Some(TableSampleKind::AfterTableAlias(sample)) = sample {
1880-
write!(f, "{sample}")?;
1880+
write!(f, " {sample}")?;
18811881
}
18821882
Ok(())
18831883
}

tests/sqlparser_common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15157,7 +15157,7 @@ fn parse_pipeline_operator() {
1515715157

1515815158
// tablesample pipe operator
1515915159
dialects.verified_stmt("SELECT * FROM tbl |> TABLESAMPLE BERNOULLI (50)");
15160-
dialects.verified_stmt("SELECT * FROM tbl |> TABLESAMPLE SYSTEM (50)");
15160+
dialects.verified_stmt("SELECT * FROM tbl |> TABLESAMPLE SYSTEM (50 PERCENT)");
1516115161
// TODO: Technically, REPEATABLE is not available in BigQuery, but it is used with TABLESAMPLE in other dialects
1516215162
dialects.verified_stmt("SELECT * FROM tbl |> TABLESAMPLE SYSTEM (50) REPEATABLE (10)");
1516315163

0 commit comments

Comments
 (0)