Skip to content

Commit

Permalink
Bug fixes (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
genzgd authored Nov 29, 2022
1 parent 2c87ede commit 05cdf0c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ other client methods, `get_client` now accepts an optional `settings` Dict[str,
to set ClickHouse server settings. The use of `**kwargs` for this purpose is deprecated and will be removed in a future
release.

## 0.4.6, 2022-11-29

### Bug Fixes
* Fixed a major settings issue with connecting to a readonly database (introduced in v0.4.4)
* Fix for broken database setup dialog with recent Superset versions using SQLAlchemy 1.4

## 0.4.5, 2022-11-24

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion clickhouse_connect/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.5
0.4.6
4 changes: 2 additions & 2 deletions clickhouse_connect/cc_superset/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ClickHouseEngineSpec(BaseEngineSpec, BasicParametersMixin):
'P1Y': 'toStartOfYear(toDateTime({col}))',
}

sqlalchemy_uri_placeholder = 'clickhousedb+connect://user:password@host[:port][/dbname][?secure=value&=value...]'
sqlalchemy_uri_placeholder = 'clickhousedb://user:password@host[:port][/dbname][?secure=value&=value...]'
parameters_schema = ClickHouseParametersSchema()
encryption_parameters = {'secure': 'true'}

Expand Down Expand Up @@ -156,7 +156,7 @@ def get_parameters_from_uri(cls, uri: str, *_args, **_kwargs) -> BasicParameters
host=url.host,
port=url.port,
database=None if url.database == '__default__' else url.database,
query=query,
query=dict(query),
encryption=encryption)

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion clickhouse_connect/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def version():


@dataclass
class CommonSetting():
class CommonSetting:
name: str
options: Sequence[Any]
default: Any
Expand Down
15 changes: 6 additions & 9 deletions clickhouse_connect/driver/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Client(ABC):
column_inserts = False
compression = None
valid_transport_settings = set()
optional_transport_settings = set()

def __init__(self, database: str, query_limit: int, uri: str, compression: Optional[str]):
"""
Expand Down Expand Up @@ -69,17 +70,13 @@ def _validate_settings(self, settings: Optional[Dict[str, Any]]) -> Dict[str, An
def _validate_setting(self, key: str, value: Any, send_anyway: bool):
if key not in self.valid_transport_settings:
setting_def = self.server_settings.get(key)
if setting_def is None:
if setting_def is None or setting_def.readonly:
if key in self.optional_transport_settings:
return None
if send_anyway:
logger.warning('Attempting to send unrecognized setting %s', key)
logger.warning('Attempting to send unrecognized or readonly setting %s', key)
else:
raise ProgrammingError(
f'Setting {key} is not recognized by this ClickHouse server') from None
elif setting_def.readonly:
if send_anyway:
logger.warning('Attempting to send readonly setting %s', key)
else:
raise ProgrammingError(f'Setting {key} is readonly') from None
raise ProgrammingError(f'Setting {key} is unknown or readonly') from None
if isinstance(value, bool):
return '1' if value else '0'
return str(value)
Expand Down
5 changes: 3 additions & 2 deletions clickhouse_connect/driver/httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@
class HttpClient(Client):
valid_transport_settings = {'database', 'buffer_size', 'session_id', 'compress', 'decompress',
'session_timeout', 'session_check', 'query_id', 'quota_key', 'wait_end_of_query',
'send_progress_in_http_headers', 'http_headers_progress_interval_ms',
'enable_http_compression'}
}
optional_transport_settings = {'send_progress_in_http_headers', 'http_headers_progress_interval_ms',
'enable_http_compression'}

# pylint: disable=too-many-arguments,too-many-locals,too-many-branches,too-many-statements
def __init__(self,
Expand Down

0 comments on commit 05cdf0c

Please sign in to comment.