fix(athena): quote schema/database identifiers in table prefix to handle hyphenated names#2657
Open
hirenkumar-n-dholariya wants to merge 1 commit intosodadata:v3from
Open
fix(athena): quote schema/database identifiers in table prefix to handle hyphenated names#2657hirenkumar-n-dholariya wants to merge 1 commit intosodadata:v3from
hirenkumar-n-dholariya wants to merge 1 commit intosodadata:v3from
Conversation
…ted names (sodadata#2483) Database and schema names in AWS Athena can contain hyphen (-) characters. Without quoting, these names are misinterpreted by the SQL query engine, causing query failures. The _create_table_prefix() method was returning self.schema unquoted, which meant any schema or database name with special characters like hyphens would produce invalid SQL. Fix: wrap the schema in double quotes in _create_table_prefix() so the generated SQL becomes: SELECT * FROM "my-schema".my_table Fixes sodadata#2483
|
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.



Problem
AWS Athena database and schema names can contain hyphen (-) characters.
The current code returns self.schema unquoted in _create_table_prefix(),
causing SQL query failures when hyphens are present:
SELECT * FROM my-schema.my_table ← SQL engine misreads the hyphen
Root Cause
In data_source.py, the _create_table_prefix() method returns:
return self.schema
This bare, unquoted value is then used directly in qualified_table_name() to build SQL strings, with no protection against special characters.
Fix
Wrap the schema in double quotes:
if self.schema:
return f'"{self.schema}"'
return None
This produces valid SQL: SELECT * FROM "my-schema".my_table
Impact
References