# TQL CTE Support, PromQL Compatibility Enhancements, and Remote WAL Trimming Optimization | Greptime Biweekly Report

Source: https://greptime.com/blogs/2025-08-20-greptimedb-biweekly-report

## Summary 

Together with our global community of contributors, GreptimeDB continues to evolve and flourish as a growing open-source project. We are grateful to each and every one of you.

Below are the highlights among recent commits:

- Introduced CTE in TQL, allowing hybrid usage with SQL CTEs for more flexible queries.
- Added `mysql.prepared_stmt_cache_size` configuration to control the number of cached prepared statements.
- Aligned the behavior of `label_join` and `label_replace` with Prometheus, improving PromQL expression compatibility.
- Implemented last-not-null and last-row deduplicate strategies for the Flat Parquet format.

## Contributors

For the past two weeks, our community has been super active with a total of **116 PRs** merged. **6 PRs** from **3 individual contributors** merged successfully and lots pending to be merged. 

Congrats on becoming our most active contributors in the past 2 weeks:

- @**[kemingy](https://github.com/kemingy)** *[docs#2033](https://github.com/GreptimeTeam/docs/pull/2033)*
- @**[sunheyi6](https://github.com/sunheyi6)** *[db#6639](https://github.com/GreptimeTeam/greptimedb/pull/6639)*
- @**[yihong0618](https://github.com/yihong0618)** *[db#6720](https://github.com/GreptimeTeam/greptimedb/pull/6720) [db#6718](https://github.com/GreptimeTeam/greptimedb/pull/6718) [db#6714](https://github.com/GreptimeTeam/greptimedb/pull/6714) [db#6708](https://github.com/GreptimeTeam/greptimedb/pull/6708)*


👏 Welcome @*[kemingy](https://github.com/kemingy)* to the community as a new contributor with a successfully merged PR, and more PRs from other individual contributors are waiting to be merged.

<figure>
<img src="/blogs/2025-08-20-greptimedb-biweekly-report/greptimedbnewcontributor.png" alt="（Figure 1: New Contributor of GreptimeDB）" style="width: 70%; margin: 0 auto"/>
<figcaption>（Figure 1: New Contributor of GreptimeDB）</figcaption>
</figure>

👏 A big THANK YOU to all our members and contributors! It is people like you who are making GreptimeDB a great product. Let's build an even greater community together.

## Highlights of Recent PRs

### [db#6639 Added `mysql.prepared_stmt_cache_size` Configuration](https://github.com/GreptimeTeam/greptimedb/issues/6639)

Introduced a new configuration to control the number of cached MySQL prepared statements. The default value is 10000.

### [db#6645 TQL Support for CTE (Common Table Expression)](https://github.com/GreptimeTeam/greptimedb/issues/6645)

Added CTE support for TQL, allowing hybrid usage with SQL CTEs. For example, you can first query data using TQL and then filter it via SQL subqueries for more flexible query combinations.

```sql
-- TQL CTE with column aliases
WITH tql (the_timestamp, the_value) as (
    TQL EVAL (0, 40, '10s') metric
)
SELECT * FROM tql;

+---------------------+-----------+
| the_timestamp       | the_value |
+---------------------+-----------+
| 1970-01-01T00:00:00 | 0.0       |
| 1970-01-01T00:00:10 | 8.0       |
| 1970-01-01T00:00:20 | 8.0       |
| 1970-01-01T00:00:30 | 2.0       |
| 1970-01-01T00:00:40 | 3.0       |
+---------------------+-----------+

-- Hybrid CTEs (TQL + SQL)
WITH 
    tql_data (ts, val) AS (TQL EVAL (0, 40, '10s') metric),
    filtered AS (SELECT * FROM tql_data WHERE val > 5)
SELECT count(*) FROM filtered;

+----------+
| count(*) |
+----------+
| 2        |
+----------+
```

### [db#6714](https://github.com/GreptimeTeam/greptimedb/issues/6714) [db#6720 Improved PromQL Expression Compatibility](https://github.com/GreptimeTeam/greptimedb/issues/6720)

Fixed `label_join` and `label_replace` behaviors to align with Prometheus, enhancing PromQL expression compatibility.

### [db#6691 Added SQL Formatting HTTP Endpoint](https://github.com/GreptimeTeam/greptimedb/issues/6691)

Introduced the /v1/sql/format endpoint for SQL formatting.

Example:

```bash
curl -s "http://localhost:4000/v1/sql/format?sql=select%201%20as%20x"
```

Output:

```bash
{
  "formatted": "SELECT 1 AS x;"
}
```

### [db#6741 Optimized Remote WAL Pruning Strategy](https://github.com/GreptimeTeam/greptimedb/issues/6741)

Used estimated data size from statistics to prune WAL, ensuring that Datanode startup does not replay excessive data even in worst-case scenarios.

### [db#6709](https://github.com/GreptimeTeam/greptimedb/issues/6789) [db#6695 Deduplication Strategies for Flat Parquet Format](https://github.com/GreptimeTeam/greptimedb/issues/6695)

Added support for last-not-null and last-row deduplication strategies.

## Good First Issue 

### [Issue#6287 Allows users to specify date and timestamp formats when using `COPY TO`](https://github.com/GreptimeTeam/greptimedb/issues/6287)

Keywords: Timestamp format

Difficulty: Simple

### [Issue#6286 Supports exporting compressed CSV or JSON files](https://github.com/GreptimeTeam/greptimedb/issues/6286)

Keywords: Data export

Difficulty: Simple

### [Issue #6334 Enhances `KILL` support for `INSERT INTO SELECT` queries](https://github.com/GreptimeTeam/greptimedb/issues/6334)

Keywords: Query engine

Difficulty: Medium
