[fix](nereids) Fix table name case-sensitivity issue when binding columns for external tables#60636
Merged
CalvinKirs merged 1 commit intoapache:tmp_tpc_preview4-myskfrom Feb 10, 2026
Conversation
…umns for external tables Proposed changes Fix the issue where column binding fails for external tables (Hive, Iceberg, etc.) when users reference table names with original case in SQL. Problem When querying external Hive tables, the following SQL fails: SELECT * FROM TPCH50.DIM_LINEITEM_CORE_OD001_V1 WHERE DIM_LINEITEM_CORE_OD001_V1.dt = '20260108' LIMIT 10; -- Error: Unknown column 'dt' in 'DIM_LINEITEM_CORE_OD001_V1' in FILTER clause But using an alias works: SELECT * FROM TPCH50.DIM_LINEITEM_CORE_OD001_V1 AS DIM_LINEITEM_CORE_OD001_V1 WHERE DIM_LINEITEM_CORE_OD001_V1.dt = '20260108' LIMIT 10; -- Success Root Cause 1. Hive Metastore stores table names in lowercase (e.g., dim_lineitem_core_od001_v1) 2. The slot qualifier uses table.getName() which returns the lowercase HMS table name 3. Users reference the table with original case in SQL (e.g., DIM_LINEITEM_CORE_OD001_V1.dt) 4. ExpressionAnalyzer.sameTableName() performs case-sensitive comparison when lower_case_table_names != 1, causing binding to fail Solution Change sameTableName() to always use case-insensitive comparison for table names. This is consistent with: - Catalog name comparison (already case-insensitive at line 1079) - Database name comparison (already case-insensitive at line 1092)
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
d09a137
into
apache:tmp_tpc_preview4-mysk
5 of 12 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…
Proposed changes
Fix the issue where column binding fails for external tables (Hive, Iceberg, etc.) when users reference table names with original case in SQL.
Problem
When querying external Hive tables, the following SQL fails: SELECT * FROM TPCH50.DIM_LINEITEM_CORE_OD001_V1
WHERE DIM_LINEITEM_CORE_OD001_V1.dt = '20260108' LIMIT 10; -- Error: Unknown column 'dt' in 'DIM_LINEITEM_CORE_OD001_V1' in FILTER clause But using an alias works:
SELECT * FROM TPCH50.DIM_LINEITEM_CORE_OD001_V1 AS DIM_LINEITEM_CORE_OD001_V1 WHERE DIM_LINEITEM_CORE_OD001_V1.dt = '20260108' LIMIT 10; -- Success
Root Cause
Change sameTableName() to always use case-insensitive comparison for table names. This is consistent with:
What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)