-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add generic options and remove schema options
- Loading branch information
1 parent
43c6b56
commit fd3f972
Showing
27 changed files
with
1,076 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# | ||
# Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved. | ||
|
||
from typing import List | ||
|
||
from sqlalchemy.exc import ArgumentError | ||
|
||
|
||
class NoPrimaryKeyError(ArgumentError): | ||
def __init__(self, target: str): | ||
super().__init__(f"Table {target} required primary key.") | ||
|
||
|
||
class UnsupportedPrimaryKeysAndForeignKeysError(ArgumentError): | ||
def __init__(self, target: str): | ||
super().__init__(f"Primary key and foreign keys are not supported in {target}.") | ||
|
||
|
||
class RequiredParametersNotProvidedError(ArgumentError): | ||
def __init__(self, target: str, parameters: List[str]): | ||
super().__init__( | ||
f"{target} requires the following parameters: %s." % ", ".join(parameters) | ||
) | ||
|
||
|
||
class UnexpectedTableOptionKeyError(ArgumentError): | ||
def __init__(self, expected: str, actual: str): | ||
super().__init__(f"Expected table option {expected} but got {actual}.") | ||
|
||
|
||
class OptionKeyNotProvidedError(ArgumentError): | ||
def __init__(self, target: str): | ||
super().__init__( | ||
f"Expected option key in {target} option but got NoneType instead." | ||
) | ||
|
||
|
||
class UnexpectedOptionParameterTypeError(ArgumentError): | ||
def __init__(self, parameter_name: str, target: str, types: List[str]): | ||
super().__init__( | ||
f"Parameter {parameter_name} of {target} requires to be one" | ||
f" of following types: {', '.join(types)}." | ||
) | ||
|
||
|
||
class CustomOptionsAreOnlySupportedOnSnowflakeTables(ArgumentError): | ||
def __init__(self): | ||
super().__init__( | ||
"Identifier, Literal, TargetLag and other custom options are only supported on Snowflake tables." | ||
) | ||
|
||
|
||
class UnexpectedOptionTypeError(ArgumentError): | ||
def __init__(self, options: List[str]): | ||
super().__init__( | ||
f"The following options are either unsupported or should be defined using a Snowflake table: {', '.join(options)}." | ||
) | ||
|
||
|
||
class InvalidTableParameterTypeError(ArgumentError): | ||
def __init__(self, name: str, input_type: str, expected_types: List[str]): | ||
expected_types_str = "', '".join(expected_types) | ||
super().__init__( | ||
f"Invalid parameter type '{input_type}' provided for '{name}'. " | ||
f"Expected one of the following types: '{expected_types_str}'.\n" | ||
) | ||
|
||
|
||
class MultipleErrors(ArgumentError): | ||
def __init__(self, errors): | ||
self.errors = errors | ||
|
||
def __str__(self): | ||
return "\n ".join(str(e) for e in self.errors) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.