Skip to content

Apache DataFusion SQL Query Engine

Bug fix : fix the bug in docs in 'cum_dist()' Example (#15618)

aditya singh rathore4ae0edea8eb7
diff --git a/datafusion/functions-window/src/cume_dist.rs b/datafusion/functions-window/src/cume_dist.rs
index 171ca575a9..f4089ee2fd 100644
--- a/datafusion/functions-window/src/cume_dist.rs
+++ b/datafusion/functions-window/src/cume_dist.rs
@@ -45,10 +45,13 @@ define_udwf_and_expr!(
doc_section(label = "Ranking Functions"),
description = "Relative rank of the current row: (number of rows preceding or peer with the current row) / (total rows).",
syntax_example = "cume_dist()",
- sql_example = r#"-- Example usage of the cume_dist window function:
-SELECT salary,
+ sql_example = r#"```sql
+ --Example usage of the cume_dist window function:
+ SELECT salary,
cume_dist() OVER (ORDER BY salary) AS cume_dist
-FROM employees;
+ FROM employees;
+```
+```sql
+--------+-----------+
| salary | cume_dist |
+--------+-----------+
@@ -56,7 +59,7 @@ FROM employees;
| 50000 | 0.67 |
| 70000 | 1.00 |
+--------+-----------+
-"#
+```"#
)]
#[derive(Debug)]
pub struct CumeDist {
diff --git a/docs/source/user-guide/sql/window_functions.md b/docs/source/user-guide/sql/window_functions.md
index 135c4d0e29..68a7003803 100644
--- a/docs/source/user-guide/sql/window_functions.md
+++ b/docs/source/user-guide/sql/window_functions.md
@@ -168,17 +168,22 @@ cume_dist()
#### Example
--- Example usage of the cume_dist window function:
-SELECT salary,
-cume_dist() OVER (ORDER BY salary) AS cume_dist
-FROM employees;
+```sql
+ --Example usage of the cume_dist window function:
+ SELECT salary,
+ cume_dist() OVER (ORDER BY salary) AS cume_dist
+ FROM employees;
+```
+
+```sql
+--------+-----------+
| salary | cume_dist |
+--------+-----------+
-| 30000 | 0.33 |
-| 50000 | 0.67 |
-| 70000 | 1.00 |
+| 30000 | 0.33 |
+| 50000 | 0.67 |
+| 70000 | 1.00 |
+--------+-----------+
+```
### `dense_rank`