10
10
ResultDisposition ,
11
11
ResultCompression ,
12
12
WaitTimeout ,
13
+ MetadataCommands ,
13
14
)
14
15
15
16
if TYPE_CHECKING :
@@ -635,7 +636,7 @@ def get_catalogs(
635
636
) -> "ResultSet" :
636
637
"""Get available catalogs by executing 'SHOW CATALOGS'."""
637
638
result = self .execute_command (
638
- operation = "SHOW CATALOGS" ,
639
+ operation = MetadataCommands . SHOW_CATALOGS . value ,
639
640
session_id = session_id ,
640
641
max_rows = max_rows ,
641
642
max_bytes = max_bytes ,
@@ -662,10 +663,10 @@ def get_schemas(
662
663
if not catalog_name :
663
664
raise ValueError ("Catalog name is required for get_schemas" )
664
665
665
- operation = f"SHOW SCHEMAS IN { catalog_name } "
666
+ operation = MetadataCommands . SHOW_SCHEMAS . value . format ( catalog_name )
666
667
667
668
if schema_name :
668
- operation += f" LIKE ' { schema_name } '"
669
+ operation += MetadataCommands . LIKE_PATTERN . value . format ( schema_name )
669
670
670
671
result = self .execute_command (
671
672
operation = operation ,
@@ -697,17 +698,19 @@ def get_tables(
697
698
if not catalog_name :
698
699
raise ValueError ("Catalog name is required for get_tables" )
699
700
700
- operation = "SHOW TABLES IN " + (
701
- "ALL CATALOGS"
701
+ operation = (
702
+ MetadataCommands . SHOW_TABLES_ALL_CATALOGS . value
702
703
if catalog_name in [None , "*" , "%" ]
703
- else f"CATALOG { catalog_name } "
704
+ else MetadataCommands .SHOW_TABLES .value .format (
705
+ MetadataCommands .CATALOG_SPECIFIC .value .format (catalog_name )
706
+ )
704
707
)
705
708
706
709
if schema_name :
707
- operation += f" SCHEMA LIKE ' { schema_name } '"
710
+ operation += MetadataCommands . SCHEMA_LIKE_PATTERN . value . format ( schema_name )
708
711
709
712
if table_name :
710
- operation += f" LIKE ' { table_name } '"
713
+ operation += MetadataCommands . LIKE_PATTERN . value . format ( table_name )
711
714
712
715
result = self .execute_command (
713
716
operation = operation ,
@@ -745,16 +748,16 @@ def get_columns(
745
748
if not catalog_name :
746
749
raise ValueError ("Catalog name is required for get_columns" )
747
750
748
- operation = f"SHOW COLUMNS IN CATALOG { catalog_name } "
751
+ operation = MetadataCommands . SHOW_COLUMNS . value . format ( catalog_name )
749
752
750
753
if schema_name :
751
- operation += f" SCHEMA LIKE ' { schema_name } '"
754
+ operation += MetadataCommands . SCHEMA_LIKE_PATTERN . value . format ( schema_name )
752
755
753
756
if table_name :
754
- operation += f" TABLE LIKE ' { table_name } '"
757
+ operation += MetadataCommands . TABLE_LIKE_PATTERN . value . format ( table_name )
755
758
756
759
if column_name :
757
- operation += f" LIKE ' { column_name } '"
760
+ operation += MetadataCommands . LIKE_PATTERN . value . format ( column_name )
758
761
759
762
result = self .execute_command (
760
763
operation = operation ,
0 commit comments