Skip to content

fix(query): preserve arguments after identity cast elimination - #20357

Draft
forsaken628 wants to merge 1 commit into
databendlabs:mainfrom
forsaken628:fix_check_function
Draft

fix(query): preserve arguments after identity cast elimination#20357
forsaken628 wants to merge 1 commit into
databendlabs:mainfrom
forsaken628:fix_check_function

Conversation

@forsaken628

@forsaken628 forsaken628 commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

  • Prevent scalar type checking from remapping an inner function's arguments onto the original call after an identity cast is eliminated
  • Reuse checked arguments only when the checked expression still has the same root function and arity, including alias resolution

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

AI assistance

  • AI usage: An AI coding agent assisted with implementation.
  • Responsible human: @forsaken628
  • The responsible human has read every line of this diff and can explain each change

This change is Reviewable

@github-actions github-actions Bot added the pr-bugfix this PR patches a bug in codebase label Aug 21, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 56761493ef

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

function,
args: checked_args,
..
}) => function.signature.name == checked_func_name && checked_args.len() == args.len(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Compare against the rewritten argument list

For a nonconstant positional call such as as_decimal(variant_column, 10, 2), the earlier split_off(1) moves precision and scale into params, so the checked function has one argument while args still has three. This comparison therefore marks the valid checked root as mismatched, and the fallback constructs a scalar call containing both the new parameters and all three original arguments; the as_decimal factory accepts exactly one argument, so later type checking/evaluation rejects the query. Compare with the post-rewrite arguments and add a nonconstant regression alongside the positional syntax in tests/sqllogictests/suites/query/functions/02_0056_function_semi_structureds_as.test.

AGENTS.md reference: src/query/AGENTS.md:L8-L8

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 CI Job Analysis

Workflow: 32494214357

📊 Summary

  • Total Jobs: 91
  • Failed Jobs: 1
  • Retryable: 0
  • Code Issues: 1

NO RETRY NEEDED

All failures appear to be code/test issues requiring manual fixes.

🔍 Job Details

  • linux / PROXY routing benchmark (statistics): Not retryable (Code/Test)

🤖 About

Automated analysis using job annotations to distinguish infrastructure issues (auto-retried) from code/test issues (manual fixes needed).

@forsaken628
forsaken628 marked this pull request as draft August 24, 2026 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix this PR patches a bug in codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant