[KYUUBI #6485] Fix the Presto TABLE NOT FOUND error message that failed to match
# 🔍 Description ## Issue References 🔗 This pull request fixes #6485 ## Describe Your Solution 🔧 Ignore uppercase and lowercase letters in table names when using regular expressions to match. ## Types of changes 🔖 - [x] Bugfix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Test Plan 🧪 Added unit tests when table names have capital letters. --- # Checklist 📝 - [x] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html) **Be nice. Be informative.** Closes #6605 from BruceWong96/fix-presto-regex. Closes #6485 06f737f24 [Bruce Wong] Fix typos 93071754a [Bruce Wong] Added unit tests for table names with both upper and lower case letters 9837030a1 [Bruce Wong] fix table not found Authored-by: Bruce Wong <603334301@qq.com> Signed-off-by: Cheng Pan <chengpan@apache.org>
This commit is contained in:
parent
f58f21f40c
commit
d3e17680f5
@ -143,7 +143,7 @@ class PrestoDialect(default.DefaultDialect):
|
||||
else None
|
||||
)
|
||||
regex = r"Table\ \'.*{}\'\ does\ not\ exist".format(re.escape(table_name))
|
||||
if msg and re.search(regex, msg):
|
||||
if msg and re.search(regex, msg, re.IGNORECASE):
|
||||
raise exc.NoSuchTableError(table_name)
|
||||
else:
|
||||
raise
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import re
|
||||
from builtins import str
|
||||
|
||||
import sqlalchemy
|
||||
|
||||
from pyhive.tests.sqlalchemy_test_case import SqlAlchemyTestCase
|
||||
from pyhive.tests.sqlalchemy_test_case import with_engine_connection
|
||||
from sqlalchemy import types
|
||||
@ -87,3 +92,14 @@ class TestSqlAlchemyPresto(unittest.TestCase, SqlAlchemyTestCase):
|
||||
self.assertIn('"current_timestamp"', query)
|
||||
self.assertNotIn('`select`', query)
|
||||
self.assertNotIn('`current_timestamp`', query)
|
||||
|
||||
@with_engine_connection
|
||||
def test_hash_table(self, engine, connection):
|
||||
sqlalchemy_version = float(re.search(r"^([\d]+\.[\d]+)\..+", sqlalchemy.__version__).group(1))
|
||||
if sqlalchemy_version >= 1.4:
|
||||
insp = sqlalchemy.inspect(engine)
|
||||
self.assertFalse(insp.has_table("THIS_TABLE_DOSE_NOT_EXIST"))
|
||||
self.assertFalse(insp.has_table("THIS_TABLE_DOSE_not_exist"))
|
||||
else:
|
||||
self.assertFalse(Table('THIS_TABLE_DOSE_NOT_EXIST', MetaData(bind=engine)).exists())
|
||||
self.assertFalse(Table('THIS_TABLE_DOSE_not_exits', MetaData(bind=engine)).exists())
|
||||
Loading…
Reference in New Issue
Block a user