File tree 2 files changed +18
-0
lines changed
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 10
10
from dataherald .sql_database .models .types import DatabaseConnection
11
11
from dataherald .types import DatabaseConnectionRequest
12
12
from dataherald .utils .encrypt import FernetEncrypt
13
+ from dataherald .utils .error_codes import CustomError
14
+
15
+
16
+ class SchemaNotSupportedError (CustomError ):
17
+ pass
13
18
14
19
15
20
class DatabaseConnectionService :
@@ -98,6 +103,18 @@ def create(
98
103
file_storage = database_connection_request .file_storage ,
99
104
metadata = database_connection_request .metadata ,
100
105
)
106
+ if database_connection .schemas and database_connection .dialect in [
107
+ "redshift" ,
108
+ "awsathena" ,
109
+ "mssql" ,
110
+ "mysql" ,
111
+ "clickhouse" ,
112
+ "duckdb" ,
113
+ ]:
114
+ raise SchemaNotSupportedError (
115
+ "Schema not supported for this db" ,
116
+ description = f"The { database_connection .dialect } dialect doesn't support schemas" ,
117
+ )
101
118
if not database_connection .schemas :
102
119
database_connection .schemas = self .get_current_schema (database_connection )
103
120
Original file line number Diff line number Diff line change 19
19
"SQLGenerationNotFoundError" : "sql_generation_not_found" ,
20
20
"NLGenerationError" : "nl_generation_not_created" ,
21
21
"MalformedGoldenSQLError" : "invalid_golden_sql" ,
22
+ "SchemaNotSupportedError" : "schema_not_supported" ,
22
23
}
23
24
24
25
You can’t perform that action at this time.
0 commit comments