feat: implement csv upload configuration func for the schema enforcement (#9734)

* Implement csv upload func for schema enforcement

Implement function controlled csv upload schema

Refactor + fix tests

Fixing hive as well

* Add explore_db to the extras

Co-authored-by: bogdan kyryliuk <bogdankyryliuk@dropbox.com>
This commit is contained in:
Bogdan
2020-05-21 13:49:53 -07:00
committed by GitHub
parent 333dc8529e
commit 3e8e441bfc
6 changed files with 275 additions and 183 deletions

View File

@@ -609,7 +609,13 @@ class Database(
def get_schema_access_for_csv_upload( # pylint: disable=invalid-name
self,
) -> List[str]:
return self.get_extra().get("schemas_allowed_for_csv_upload", [])
allowed_databases = self.get_extra().get("schemas_allowed_for_csv_upload", [])
if hasattr(g, "user"):
extra_allowed_databases = config["ALLOWED_USER_CSV_SCHEMA_FUNC"](
self, g.user
)
allowed_databases += extra_allowed_databases
return sorted(set(allowed_databases))
@property
def sqlalchemy_uri_decrypted(self) -> str: