|
| 1 | +--- |
| 2 | +title: "This Week in Databend #87" |
| 3 | +date: 2023-04-01 |
| 4 | +slug: 2023-04-01-databend-weekly |
| 5 | +tags: [databend, weekly] |
| 6 | +description: "Stay up to date with the latest weekly developments on Databend!" |
| 7 | +contributors: |
| 8 | + - name: andylokandy |
| 9 | + - name: ariesdevil |
| 10 | + - name: b41sh |
| 11 | + - name: BohuTANG |
| 12 | + - name: dantengsky |
| 13 | + - name: Dousir9 |
| 14 | + - name: drmingdrmer |
| 15 | + - name: everpcpc |
| 16 | + - name: jun0315 |
| 17 | + - name: leiysky |
| 18 | + - name: lichuang |
| 19 | + - name: PsiACE |
| 20 | + - name: RinChanNOWWW |
| 21 | + - name: rkmdCodes |
| 22 | + - name: SkyFan2002 |
| 23 | + - name: soyeric128 |
| 24 | + - name: sundy-li |
| 25 | + - name: TCeason |
| 26 | + - name: Xuanwo |
| 27 | + - name: xudong963 |
| 28 | + - name: youngsofun |
| 29 | + - name: zhang2014 |
| 30 | + - name: zhyass |
| 31 | +authors: |
| 32 | + - name: PsiACE |
| 33 | + url: https://github.com/psiace |
| 34 | + image_url: https://github.com/psiace.png |
| 35 | +--- |
| 36 | + |
| 37 | +[Databend](https://github.com/datafuselabs/databend) is a modern cloud data warehouse, serving your massive-scale analytics needs at low cost and complexity. Open source alternative to Snowflake. Also available in the cloud: <https://app.databend.com> . |
| 38 | + |
| 39 | +## What's On In Databend |
| 40 | + |
| 41 | +Stay connected with the latest news about Databend. |
| 42 | + |
| 43 | +### Window Function |
| 44 | + |
| 45 | +Aggregate window functions can operate on a group of rows and return a single value for each row in the underlying query. The `OVER` clause specifies how to partition the rows in the result set. When used with `GROUP BY`, aggregate window functions do not collapse rows but instead return all rows in the result set. |
| 46 | + |
| 47 | +```sql |
| 48 | +-- use aggrerate window function |
| 49 | +SELECT date, AVG(amount) over (partition by date) |
| 50 | +FROM BookSold |
| 51 | + |
| 52 | +June 21|544.0 |
| 53 | +June 21|544.0 |
| 54 | +June 22|454.5 |
| 55 | +June 22|454.5 |
| 56 | +June 23|643.0 |
| 57 | +June 23|643.0 |
| 58 | +``` |
| 59 | + |
| 60 | +Databend supports all aggregate functions as aggregate window functions. |
| 61 | + |
| 62 | +- [Doc | (draft) Aggregate Window Functions](https://databend.rs/doc/sql-functions/window-functions/aggregate-window-functions) |
| 63 | +- [PR #10700 | feat(window): initial impl window function](https://github.com/datafuselabs/databend/pull/10700). |
| 64 | + |
| 65 | +### Suggest Function Name on Typos |
| 66 | + |
| 67 | +Databend has added an intelligent feature that automatically provides the closest matching item when you enter an incorrect function name. |
| 68 | + |
| 69 | +```sql |
| 70 | +#> select base64(1); |
| 71 | +ERROR 1105 (HY000) at line 1: Code: 1008, displayText = error: |
| 72 | + --> SQL:1:8 |
| 73 | + | |
| 74 | +1 | select base64(1) |
| 75 | + | ^^^^^^^^^ no function matches the given name: 'base64', do you mean 'to_base64'? |
| 76 | +``` |
| 77 | + |
| 78 | +- [PR | feat(planner): suggest function name on typo](https://github.com/datafuselabs/databend/pull/10759) |
| 79 | + |
| 80 | +## Code Corner |
| 81 | + |
| 82 | +Discover some fascinating code snippets or projects that showcase our work or learning journey. |
| 83 | + |
| 84 | +### Dump Running Async Task Stack |
| 85 | + |
| 86 | +Databend now supports dumping the running async task stacks. Simply visit `http://<admin_api_address>/debug/async_tasks/dump` to capture it in your browser. |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | +Calling the `async_backtrace::taskdump_tree` function can obtain information about the asynchronous task tree (collected by `#[async_backtrace::framed]`). |
| 91 | + |
| 92 | +```rust |
| 93 | + let tree = |
| 94 | + async_backtrace::taskdump_tree(req.map(|x| x.wait_for_running_tasks).unwrap_or(false)); |
| 95 | +``` |
| 96 | + |
| 97 | +Tasks are divided into regular tasks and polling tasks (marked with `[POLLING]`). Record the stack information for each task, and output it to a string sorted by stack depth. |
| 98 | + |
| 99 | +```rust |
| 100 | + for mut tasks in [tasks, polling_tasks] { |
| 101 | + tasks.sort_by(|l, r| Ord::cmp(&l.stack_frames.len(), &r.stack_frames.len())); |
| 102 | + |
| 103 | + for item in tasks.into_iter().rev() { |
| 104 | + for frame in item.stack_frames { |
| 105 | + writeln!(output, "{}", frame).unwrap(); |
| 106 | + } |
| 107 | + |
| 108 | + writeln!(output).unwrap(); |
| 109 | + } |
| 110 | + } |
| 111 | +``` |
| 112 | + |
| 113 | +To learn more about how it works, refer to the following link: |
| 114 | + |
| 115 | +- [PR | feat(query): try support dump running async task stack](https://github.com/datafuselabs/databend/pull/10830) |
| 116 | + |
| 117 | +### New Way to Integrate with Jupyter Notebook |
| 118 | + |
| 119 | +As described in [Doc | Visualization Databend Data in Jupyter Notebook](https://databend.rs/doc/integrations/gui-tool/jupyter), we can use Jupyter Notebook to explore data in Databend. |
| 120 | + |
| 121 | + |
| 122 | + |
| 123 | +However, through the trick of magic, [ipython-sql](https://github.com/catherinedevlin/ipython-sql) provides another interesting way to make SQL queries look like they are running in SQL cells and maintain seamless integration with Python. |
| 124 | + |
| 125 | +**Install Dependencies** |
| 126 | + |
| 127 | +```bash |
| 128 | +pip install ipython-sql databend-sqlalchemy |
| 129 | +``` |
| 130 | + |
| 131 | +**Work with Jupyter Notebook** |
| 132 | + |
| 133 | +```sql |
| 134 | +In [1]: %load_ext sql |
| 135 | + |
| 136 | +In [2]: %%sql databend://{username}:{password}@{host_port_name}/{database_name}?secure=false |
| 137 | + ...: SHOW DATABASES; |
| 138 | + |
| 139 | +In [3]: result = %%sql SELECT * FROM numbers(100); |
| 140 | + |
| 141 | +In [4]: %matplotlib inline |
| 142 | + ...: df = result.DataFrame() |
| 143 | + ...: df.plot() |
| 144 | +``` |
| 145 | + |
| 146 | +## Highlights |
| 147 | + |
| 148 | +Here are some noteworthy items recorded here, perhaps you can find something that interests you. |
| 149 | + |
| 150 | +- *[Connecting to Databend with DBeaver](https://databend.rs/blog/dbeaver)*, either by selecting the pre-configured MySQL driver or adding the Databend JDBC driver. |
| 151 | +- Databend provides integration with Redash to help you gain better insights into your data. *[Doc | Integrations - Redash](https://databend.rs/doc/integrations/gui-tool/redash)* |
| 152 | +- Master how to display information of columns in a given table. *[Doc | SHOW COLUMNS](https://databend.rs/doc/sql-commands/show/show-full-columns)* |
| 153 | +- Databend now supports `generate_series` and `range` table functions. |
| 154 | +- Databend now supports the `ai_embedding_vector` function, which returns a 1536-dimensional f32 vectors generated by the OpenAI Embeddings API. |
| 155 | +- Databend added support for `[CREATE | DROP | SHOW] SHARE ENDPOINT` DDL. |
| 156 | + |
| 157 | +## What's Up Next |
| 158 | + |
| 159 | +We're always open to cutting-edge technologies and innovative ideas. You're more than welcome to join the community and bring them to Databend. |
| 160 | + |
| 161 | +### Collect Metrics from Sled |
| 162 | + |
| 163 | +[sled](https://github.com/spacejam/sled) is an embedded database. It has a metrics feature that exposed some metrics. |
| 164 | + |
| 165 | +Databend Meta Service uses [sled](https://github.com/datafuse-extras/sled) as the underlying Key-Value storage. We expect to obtain more metrics about sled in order to further improve observability and help with optimization. |
| 166 | + |
| 167 | +[Issue #7233 | make use of sled metrics feature for collect sled metrics](https://github.com/datafuselabs/databend/issues/7233) |
| 168 | + |
| 169 | +Please let us know if you're interested in contributing to this issue, or pick up a good first issue at <https://link.databend.rs/i-m-feeling-lucky> to get started. |
| 170 | + |
| 171 | +## New Contributors |
| 172 | + |
| 173 | +We always open arms to everyone and can't wait to see how you'll help our community grow and thrive. |
| 174 | + |
| 175 | +- [@rkmdCodes](https://github.com/rkmdCodes) made their first contribution in [#10269](https://github.com/datafuselabs/databend/pull/10269). This pull request improves the error string and makes the prompt clearer. |
| 176 | + |
| 177 | +## Changelog |
| 178 | + |
| 179 | +You can check the changelog of Databend Nightly for details about our latest developments. |
| 180 | + |
| 181 | +**Full Changelog**: <https://github.com/datafuselabs/databend/compare/v1.0.33-nightly...v1.0.46-nightly> |
0 commit comments