agents/commit-and-pr.md
fix(storage): avoid stale snapshot (#19174) or feat: support self join elimination (#19169).rfc, feat, fix, refactor, ci, docs, and chore; prefer ci for test-only or CI-only changes.query or admin-status.PULL_REQUEST_TEMPLATE.md, including checkboxes, verification, and screenshots when needed.origin.gh tooling 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.
contains_subquery() function to detect subqueries in AST expressionsexecute_subquery_for_scalar() to execute and extract scalar values from subqueriesbind_table_args to try constant folding first, then fall back to subquery executionScalar::Null for empty subquery results (aligns with LeftSingleJoin behavior)Added tests in 02_0063_function_generate_series.test for:
generate_series with subquery argumentsrange with subquery arguments