Skip to content

parse_functions: find functions inside FROM-clause subqueries, joins and table-function arguments - #17

Open
asubbarao wants to merge 1 commit into
hotdata-dev:mainfrom
asubbarao:fix/parse-functions-from-subqueries
Open

asubbarao wants to merge 1 commit into
hotdata-dev:mainfrom
asubbarao:fix/parse-functions-from-subqueries

Conversation

@asubbarao

Copy link
Copy Markdown

parse_function_names and parse_functions skip everything in the FROM clause: subqueries, both sides of a join, and table-function arguments, as well as scalar subqueries. The community build (parser_tools pinned at 6a94f2b) returns [] for the first query below.

SELECT parse_function_names('SELECT * FROM (SELECT avg(n) AS a FROM range(5) t(n)) s');
-- before: []    after: [avg]

The traversal now descends into from_table (join sides and conditions, subquery references, table-function arguments and subqueries) and into SubqueryExpression, following the same table-reference pattern parse_tables uses.

query before after
FROM (SELECT avg(n) …) s [] [avg]
FROM (SELECT upper(x) …) a JOIN (SELECT lower(y) …) b [] [upper, lower]
FROM range(abs(-5)) [] [abs]
SELECT (SELECT sum(1)) WHERE x IN (SELECT length(z) …) [] [sum, length]

Verified against DuckDB v1.4.4 (this repo's pin): the four cases are added to both parse_function_names.test and parse_functions.test. On the unpatched source both files fail ([] <> [avg], 2 of 11 test cases); with the patch all 11 test cases pass.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants