Skip to content

Conversation

@KKould
Copy link
Member

@KKould KKould commented Nov 24, 2025

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

Summary

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):

This change is Reviewable

@github-actions github-actions bot added the pr-feature this PR introduces a new feature to the codebase label Nov 24, 2025
@KKould KKould marked this pull request as ready for review November 24, 2025 05:33
@KKould KKould self-assigned this Nov 24, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for position-based column references (using $1, $2, etc. syntax) in common SQL queries such as subqueries, CTEs, and PIVOT operations. Previously, this syntax was only available for stage queries (file reads).

  • Adds reset_result_column_positions() method to assign 1-based positions to query result columns
  • Calls the reset method at the end of query binding to enable position-based references
  • Adds comprehensive test coverage for the new feature

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/query/sql/src/planner/binder/bind_context.rs Implements reset_result_column_positions() method to assign 1-based positions to columns in bind context
src/query/sql/src/planner/binder/bind_query/bind.rs Calls reset_result_column_positions() after query binding to enable position-based column references
tests/sqllogictests/suites/query/select.test Adds comprehensive tests for position-based column references in subqueries, CTEs, and PIVOT operations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@youngsofun youngsofun merged commit 51133e7 into databendlabs:main Nov 24, 2025
174 of 176 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature this PR introduces a new feature to the codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: support position column in common sql query

3 participants