@@ -38,12 +38,7 @@ pub enum OdbcVariant {
3838impl super :: SqlDialect for OdbcDialect {
3939 fn sql_list_catalogs ( & self ) -> String {
4040 match self . variant {
41- OdbcVariant :: Snowflake => {
42- "SELECT database_name AS catalog_name \
43- FROM snowflake.information_schema.databases \
44- ORDER BY database_name"
45- . into ( )
46- }
41+ OdbcVariant :: Snowflake => "SHOW DATABASES" . into ( ) ,
4742 _ => {
4843 "SELECT DISTINCT catalog_name FROM information_schema.schemata \
4944 ORDER BY catalog_name"
@@ -53,17 +48,13 @@ impl super::SqlDialect for OdbcDialect {
5348 }
5449
5550 fn sql_list_schemas ( & self , catalog : & str ) -> String {
56- let catalog = catalog. replace ( '\'' , "''" ) ;
5751 match self . variant {
5852 OdbcVariant :: Snowflake => {
5953 let catalog_ident = catalog. replace ( '"' , "\" \" " ) ;
60- format ! (
61- "SELECT schema_name \
62- FROM \" {catalog_ident}\" .information_schema.schemata \
63- ORDER BY schema_name"
64- )
54+ format ! ( "SHOW SCHEMAS IN DATABASE \" {catalog_ident}\" " )
6555 }
6656 _ => {
57+ let catalog = catalog. replace ( '\'' , "''" ) ;
6758 format ! (
6859 "SELECT DISTINCT schema_name FROM information_schema.schemata \
6960 WHERE catalog_name = '{catalog}' ORDER BY schema_name"
@@ -73,19 +64,17 @@ impl super::SqlDialect for OdbcDialect {
7364 }
7465
7566 fn sql_list_tables ( & self , catalog : & str , schema : & str ) -> String {
76- let schema = schema. replace ( '\'' , "''" ) ;
7767 match self . variant {
7868 OdbcVariant :: Snowflake => {
7969 let catalog_ident = catalog. replace ( '"' , "\" \" " ) ;
70+ let schema_ident = schema. replace ( '"' , "\" \" " ) ;
8071 format ! (
81- "SELECT table_name, table_type \
82- FROM \" {catalog_ident}\" .information_schema.tables \
83- WHERE table_schema = '{schema}' \
84- ORDER BY table_name"
72+ "SHOW OBJECTS IN SCHEMA \" {catalog_ident}\" .\" {schema_ident}\" "
8573 )
8674 }
8775 _ => {
8876 let catalog = catalog. replace ( '\'' , "''" ) ;
77+ let schema = schema. replace ( '\'' , "''" ) ;
8978 format ! (
9079 "SELECT DISTINCT table_name, table_type FROM information_schema.tables \
9180 WHERE table_catalog = '{catalog}' AND table_schema = '{schema}' \
@@ -96,20 +85,19 @@ impl super::SqlDialect for OdbcDialect {
9685 }
9786
9887 fn sql_list_columns ( & self , catalog : & str , schema : & str , table : & str ) -> String {
99- let schema = schema. replace ( '\'' , "''" ) ;
100- let table = table. replace ( '\'' , "''" ) ;
10188 match self . variant {
10289 OdbcVariant :: Snowflake => {
10390 let catalog_ident = catalog. replace ( '"' , "\" \" " ) ;
91+ let schema_ident = schema. replace ( '"' , "\" \" " ) ;
92+ let table_ident = table. replace ( '"' , "\" \" " ) ;
10493 format ! (
105- "SELECT column_name, data_type \
106- FROM \" {catalog_ident}\" .information_schema.columns \
107- WHERE table_schema = '{schema}' AND table_name = '{table}' \
108- ORDER BY ordinal_position"
94+ "SHOW COLUMNS IN TABLE \" {catalog_ident}\" .\" {schema_ident}\" .\" {table_ident}\" "
10995 )
11096 }
11197 _ => {
11298 let catalog = catalog. replace ( '\'' , "''" ) ;
99+ let schema = schema. replace ( '\'' , "''" ) ;
100+ let table = table. replace ( '\'' , "''" ) ;
113101 format ! (
114102 "SELECT column_name, data_type FROM information_schema.columns \
115103 WHERE table_catalog = '{catalog}' AND table_schema = '{schema}' \
0 commit comments