- Use a Conventional-style subject such as
fix(storage): avoid stale snapshot (#19174)orfeat: support self join elimination (#19169). - Keep the first line imperative and under 72 characters.
- Keep each commit scoped to one logical change set.
- Include formatting and linting updates in the same patch when they belong to the change.
- Allowed PR title types are
rfc,feat,fix,refactor,ci,docs, andchore; prefercifor test-only or CI-only changes. - Optional PR title scopes may contain only lowercase letters, digits, and hyphens, such as
queryoradmin-status. - Outline motivation, implementation notes, and validation commands.
- Link issues or RFCs when relevant.
- Follow
PULL_REQUEST_TEMPLATE.md, including checkboxes, verification, and screenshots when needed. - Attach screenshots or sample queries when UI, SQL plans, or system tables change.
- Call out rollout risks such as migrations, config toggles, or backfills.
- Push the branch to your fork and create the PR into
origin. - You can use
ghtooling for the PR flow.
I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
## Summary
- Enable table functions like `generate_series` and `range` to accept scalar subqueries as arguments
- Return NULL for empty scalar subqueries to align with existing scalar subquery semantics
## Changes
This PR enables SQL like:
```sql
SELECT generate_series AS install_date
FROM generate_series(
(SELECT count() FROM numbers(10))::int,
(SELECT count() FROM numbers(39))::int
);Previously, table function arguments could only be constants. Now they can be scalar subqueries that return a single value.
- Added
contains_subquery()function to detect subqueries in AST expressions - Added
execute_subquery_for_scalar()to execute and extract scalar values from subqueries - Modified
bind_table_argsto try constant folding first, then fall back to subquery execution - The subquery executor is passed from the binder to enable runtime evaluation
- Returns
Scalar::Nullfor empty subquery results (aligns with LeftSingleJoin behavior)
- Unit Test
- Logic Test
- Benchmark Test
- No Test - Pair with the reviewer to explain why
Added tests in 02_0063_function_generate_series.test for:
generate_serieswith subquery argumentsrangewith subquery arguments
- New feature (non-breaking change which adds functionality)