Skip to content

Commit 883b896

Browse files
committed
fix(athena): only replace commas instead of all special characters in column names
1 parent c0d06c4 commit 883b896

File tree

3 files changed

+4
-4
lines changed
  • ibis/backends

3 files changed

+4
-4
lines changed

ibis/backends/sql/compilers/athena.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from ibis.backends.sql.compilers.trino import TrinoCompiler
99
from ibis.backends.sql.datatypes import AthenaType
1010

11-
_NAME_REGEX = re.compile(r'[^!"$()*,./;?@[\\\]^`{}~\n]+')
11+
_COMMA_REGEX = re.compile(r"[^,]+")
1212

1313

1414
class AthenaCompiler(TrinoCompiler):
@@ -34,7 +34,7 @@ class AthenaCompiler(TrinoCompiler):
3434

3535
@staticmethod
3636
def _gen_valid_name(name: str) -> str:
37-
return "_".join(map(str.strip, _NAME_REGEX.findall(name))) or "tmp"
37+
return ";".join(map(str.strip, _COMMA_REGEX.findall(name))) or "tmp"
3838

3939

4040
compiler = AthenaCompiler()

ibis/backends/tests/snapshots/test_sql/test_isin_bug/athena/out.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ SELECT
55
FROM "t" AS "t0"
66
WHERE
77
"t0"."x" > 2
8-
) AS "InSubquery_x"
8+
) AS "InSubquery(x)"
99
FROM "t" AS "t0"

ibis/backends/tests/snapshots/test_sql/test_to_sql_default_backend/athena/to_sql.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
SELECT
2-
COUNT(*) AS "CountStar"
2+
COUNT(*) AS "CountStar()"
33
FROM (
44
SELECT
55
*

0 commit comments

Comments
 (0)