fix(athena): quote schema/database identifiers in table prefix to handle hyphenated names#2657
fix(athena): quote schema/database identifiers in table prefix to handle hyphenated names#2657hirenkumar-n-dholariya wants to merge 1 commit into
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
|
|
Hi @Niels-b @bmarinovic @tomassatka 👋 I've submitted this fix for issue #2483 where AWS Athena database/schema names containing hyphens (-) cause SQL query failures because they are not quoted in the table prefix. The fix wraps the schema in double quotes in _create_table_prefix() so the generated SQL becomes "my-schema".my_table instead of my-schema.my_table. All checks are passing! Could someone please review when you get a chance? Happy to make any changes based on feedback. Thank you! |
|
I hope you're doing well! I wanted to gently follow up on this PR which addresses the Athena query failure reported in issue #2483. The fix is minimal - just wrapping the schema in double quotes in _create_table_prefix() so hyphenated database/schema names like "my-schema" are handled correctly in SQL queries. I know your time is valuable and there are many things competing for your attention. Whenever this bubbles up in your queue, even a brief comment on whether the approach looks right with PR approval would mean a lot to me as a first-time contributor on this repo. Thank you so much for your time! |
|
Hi @bmarinovic @tomassatka @Niels-b Hope you are doing well! |



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