This is an automated email from the ASF dual-hosted git repository.

richardantal pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/phoenix-queryserver.git


The following commit(s) were added to refs/heads/master by this push:
     new aea5305  PHOENIX-6727 get_view_names() returning empty list
aea5305 is described below

commit aea5305c406fece97d5e69f3056bc9a0cfe99a31
Author: Richard Antal <richard.an...@cloudera.com>
AuthorDate: Thu Jun 9 16:29:18 2022 +0200

    PHOENIX-6727 get_view_names() returning empty list
    
    Change-Id: I674d7c6a92a418aae774075c480636fbab891b41
---
 python-phoenixdb/phoenixdb/sqlalchemy_phoenix.py    | 4 ++--
 python-phoenixdb/phoenixdb/tests/test_sqlalchemy.py | 4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/python-phoenixdb/phoenixdb/sqlalchemy_phoenix.py 
b/python-phoenixdb/phoenixdb/sqlalchemy_phoenix.py
index 8661417..15acdd1 100644
--- a/python-phoenixdb/phoenixdb/sqlalchemy_phoenix.py
+++ b/python-phoenixdb/phoenixdb/sqlalchemy_phoenix.py
@@ -153,8 +153,8 @@ class PhoenixDialect(DefaultDialect):
     def get_view_names(self, connection, schema=None, **kw):
         if schema is None:
             schema = ''
-        return 
connection.connect().connection.meta().get_tables(schemaPattern=schema,
-                                                                 
typeList=('VIEW'))
+        views = 
connection.connect().connection.meta().get_tables(schemaPattern=schema, 
typeList=('VIEW',))
+        return [view['TABLE_NAME'] for view in views]
 
     def get_columns(self, connection, table_name, schema=None, **kw):
         if schema is None:
diff --git a/python-phoenixdb/phoenixdb/tests/test_sqlalchemy.py 
b/python-phoenixdb/phoenixdb/tests/test_sqlalchemy.py
index c996262..82ebcc7 100644
--- a/python-phoenixdb/phoenixdb/tests/test_sqlalchemy.py
+++ b/python-phoenixdb/phoenixdb/tests/test_sqlalchemy.py
@@ -68,6 +68,7 @@ class SQLAlchemyTest(unittest.TestCase):
                 connection.execute(text('create table ALCHEMY_TEST (ID integer 
primary key)'))
                 connection.execute(text('create table A.ALCHEMY_TEST_A (ID_A 
integer primary key)'))
                 connection.execute(text('create table B.ALCHEMY_TEST_B (ID_B 
integer primary key)'))
+                connection.execute(text('create view ALCHEMY_TEST_VIEW as 
select * from ALCHEMY_TEST'))
 
                 self.assertEqual(inspector.get_schema_names(), ['', 'A', 'B', 
'SYSTEM'])
 
@@ -76,6 +77,8 @@ class SQLAlchemyTest(unittest.TestCase):
                 self.assertEqual(inspector.get_table_names('A'), 
['ALCHEMY_TEST_A'])
                 self.assertEqual(inspector.get_table_names('B'), 
['ALCHEMY_TEST_B'])
 
+                self.assertEqual(inspector.get_view_names(), 
['ALCHEMY_TEST_VIEW'])
+
                 
self.assertEqual(inspector.get_columns('ALCHEMY_TEST').pop()['name'], 'ID')
                 self.assertEqual(
                     inspector.get_columns('ALCHEMY_TEST', '').pop()['name'], 
'ID')
@@ -87,6 +90,7 @@ class SQLAlchemyTest(unittest.TestCase):
                 self.assertTrue(engine.has_table('ALCHEMY_TEST_A', 'A'))
                 self.assertFalse(engine.has_table('ALCHEMY_TEST', 'A'))
             finally:
+                connection.execute('drop view if exists ALCHEMY_TEST_VIEW')
                 connection.execute('drop table if exists ALCHEMY_TEST')
                 connection.execute('drop table if exists A.ALCHEMY_TEST_A')
                 connection.execute('drop table if exists B.ALCHEMY_TEST_B')

Reply via email to