Skip to content

Commit

Permalink
Fix native column query
Browse files Browse the repository at this point in the history
  • Loading branch information
genzgd committed Nov 16, 2023
1 parent 77830d0 commit 5b9ed06
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dbt/adapters/clickhouse/nativeclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def command(self, sql, **kwargs):
def columns_in_query(self, sql: str, **kwargs) -> List[ClickHouseColumn]:
try:
_, columns = self._client.execute(f'{sql} LIMIT 0', with_column_types=True)
return [ClickHouseColumn.create(column.name, column.type) for column in columns]
return [ClickHouseColumn.create(column[0], column[1]) for column in columns]
except clickhouse_driver.errors.Error as ex:
raise DbtDatabaseError(str(ex).strip()) from ex

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/adapter/constraints/test_constraints.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from dbt.tests.util import get_manifest, run_dbt, run_dbt_and_capture

from tests.integration.adapter.constraints.contract_fixtures import (
from tests.integration.adapter.constraints.constraint_fixtures import (
model_schema_yml,
my_model_wrong_name_sql,
my_model_wrong_order_sql,
Expand Down
9 changes: 6 additions & 3 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ def test_config(ch_test_users, ch_test_version):
compose_file = f'{Path(__file__).parent}/docker-compose.yml'
test_host = os.environ.get('DBT_CH_TEST_HOST', 'localhost')
test_port = int(os.environ.get('DBT_CH_TEST_PORT', 8123))
test_driver = 'native' if test_port in (10900, 9000, 9440) else 'http'
client_port = int(os.environ.get('DBT_CH_TEST_CLIENT_PORT', 0))
test_driver = os.environ.get('DBT_CH_TEST_DRIVER', '').lower()
if test_driver == '':
test_driver = 'native' if test_port in (10900, 9000, 9440) else 'http'
test_user = os.environ.get('DBT_CH_TEST_USER', 'default')
test_password = os.environ.get('DBT_CH_TEST_PASSWORD', '')
test_cluster = os.environ.get('DBT_CH_TEST_CLUSTER', '')
Expand All @@ -49,7 +52,7 @@ def test_config(ch_test_users, ch_test_version):
docker = os.environ.get('DBT_CH_TEST_USE_DOCKER', '').lower() in ('1', 'true', 'yes')

if docker:
client_port = 10723
client_port = client_port or 10723
test_port = 10900 if test_driver == 'native' else client_port
try:
run_cmd(['docker-compose', '-f', compose_file, 'down', '-v'])
Expand All @@ -62,7 +65,7 @@ def test_config(ch_test_users, ch_test_version):
wait_until_responsive(timeout=30.0, pause=0.5, check=lambda: is_responsive(url))
except Exception as e:
raise Exception('Failed to run docker-compose: {}', str(e))
else:
elif not client_port:
if test_driver == 'native':
client_port = 8443 if test_port == 9440 else 8123
else:
Expand Down

0 comments on commit 5b9ed06

Please sign in to comment.