Skip to content

Commit 05fb2c8

Browse files
Merge pull request datastax#1067 from datastax/python-1205
PYTHON-1205: Fix Undefined column name native_transport_address" error when connecting to C* 4.0
2 parents 3a5bd85 + 3a2ea45 commit 05fb2c8

File tree

4 files changed

+28
-26
lines changed

4 files changed

+28
-26
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Features
66
--------
77
* Add all() function to the ResultSet API (PYTHON-1203)
88

9+
Bug Fixes
10+
---------
11+
* Make sure to only query the native_transport_address column with DSE (PYTHON-1205)
12+
913
3.21.0
1014
======
1115
January 15, 2020

build.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ schedules:
99
matrix:
1010
exclude:
1111
- python: [3.4, 3.6, 3.7, 3.8]
12-
- cassandra: ['2.1', '3.0', 'test-dse']
12+
- cassandra: ['2.1', '3.0', '4.0', 'test-dse']
1313

1414
commit_long_test:
1515
schedule: per_commit
@@ -21,7 +21,7 @@ schedules:
2121
matrix:
2222
exclude:
2323
- python: [3.4, 3.6, 3.7, 3.8]
24-
- cassandra: ['2.1', '3.0', 'test-dse']
24+
- cassandra: ['2.1', '3.0', '4.0', 'test-dse']
2525

2626
commit_branches:
2727
schedule: per_commit
@@ -34,7 +34,7 @@ schedules:
3434
matrix:
3535
exclude:
3636
- python: [3.4, 3.6, 3.7, 3.8]
37-
- cassandra: ['2.1', '3.0', 'test-dse']
37+
- cassandra: ['2.1', '3.0', '4.0', 'test-dse']
3838

3939
commit_branches_dev:
4040
schedule: per_commit
@@ -46,8 +46,8 @@ schedules:
4646
EXCLUDE_LONG=1
4747
matrix:
4848
exclude:
49-
- python: [2.7, 3.4, 3.7, 3.8]
50-
- cassandra: ['2.0', '2.1', '2.2', '3.0', 'test-dse', dse-4.8', 'dse-5.0']
49+
- python: [2.7, 3.4, 3.7, 3.6, 3.8]
50+
- cassandra: ['2.0', '2.1', '2.2', '3.0', '4.0', 'test-dse', 'dse-4.8', 'dse-5.0', 'dse-6.0', 'dse-6.8']
5151

5252
release_test:
5353
schedule: per_commit
@@ -139,7 +139,7 @@ schedules:
139139
matrix:
140140
exclude:
141141
- python: [3.4, 3.6, 3.7, 3.8]
142-
- cassandra: ['2.0', '2.1', '2.2', '3.0', 'test-dse']
142+
- cassandra: ['2.0', '2.1', '2.2', '3.0', '4.0', 'test-dse']
143143

144144
python:
145145
- 2.7
@@ -157,6 +157,7 @@ cassandra:
157157
- '2.2'
158158
- '3.0'
159159
- '3.11'
160+
- '4.0'
160161
- 'dse-4.8'
161162
- 'dse-5.0'
162163
- 'dse-5.1'
@@ -181,7 +182,7 @@ build:
181182
pip install --upgrade pip
182183
pip install -U setuptools
183184
184-
pip install git+ssh://[email protected]/riptano/ccm-private.git
185+
pip install $HOME/ccm
185186
186187
if [ -n "$CCM_IS_DSE" ]; then
187188
pip install -r test-datastax-requirements.txt

cassandra/cluster.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
from cassandra.marshal import int64_pack
8181
from cassandra.timestamps import MonotonicTimestampGenerator
8282
from cassandra.compat import Mapping
83-
from cassandra.util import _resolve_contact_points_to_string_map
83+
from cassandra.util import _resolve_contact_points_to_string_map, Version
8484

8585
from cassandra.datastax.insights.reporter import MonitorReporter
8686
from cassandra.datastax.insights.util import version_supports_insights
@@ -3324,7 +3324,7 @@ class ControlConnection(object):
33243324
_SELECT_SCHEMA_PEERS_TEMPLATE = "SELECT peer, host_id, {nt_col_name}, schema_version FROM system.peers"
33253325
_SELECT_SCHEMA_LOCAL = "SELECT schema_version FROM system.local WHERE key='local'"
33263326

3327-
_MINIMUM_NATIVE_ADDRESS_VERSION = "4.0"
3327+
_MINIMUM_NATIVE_ADDRESS_DSE_VERSION = Version("6.0.0")
33283328

33293329
_is_shutdown = False
33303330
_timeout = None
@@ -3884,14 +3884,17 @@ def _peers_query_for_version(self, connection, peers_query_template):
38843884
field named nt_col_name.
38853885
"""
38863886
host_release_version = self._cluster.metadata.get_host(connection.endpoint).release_version
3887-
if host_release_version:
3888-
use_native_address_query = host_release_version >= self._MINIMUM_NATIVE_ADDRESS_VERSION
3889-
if use_native_address_query:
3890-
select_peers_query = peers_query_template.format(nt_col_name="native_transport_address")
3891-
else:
3887+
host_dse_version = self._cluster.metadata.get_host(connection.endpoint).dse_version
3888+
uses_native_address_query = (
3889+
host_dse_version and Version(host_dse_version) >= self._MINIMUM_NATIVE_ADDRESS_DSE_VERSION)
3890+
3891+
if uses_native_address_query:
3892+
select_peers_query = peers_query_template.format(nt_col_name="native_transport_address")
3893+
elif host_release_version:
38923894
select_peers_query = peers_query_template.format(nt_col_name="rpc_address")
38933895
else:
38943896
select_peers_query = self._SELECT_PEERS
3897+
38953898
return select_peers_query
38963899

38973900
def _signal_error(self):

tests/integration/__init__.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def _get_dse_version_from_cass(cass_version):
172172
cassandra_version = Version(mcv_string)
173173

174174
CASSANDRA_VERSION = Version(mcv_string) if mcv_string else cassandra_version
175-
CCM_VERSION = cassandra_version if mcv_string else CASSANDRA_VERSION
175+
CCM_VERSION = mcv_string if mcv_string else cv_string
176176

177177
CASSANDRA_IP = os.getenv('CLUSTER_IP', '127.0.0.1')
178178
CASSANDRA_DIR = os.getenv('CASSANDRA_DIR', None)
@@ -454,19 +454,13 @@ def use_cluster(cluster_name, nodes, ipformat=None, start=True, workloads=None,
454454
set_default_cass_ip()
455455

456456
if ccm_options is None and DSE_VERSION:
457-
ccm_options = {"version": DSE_VERSION}
457+
ccm_options = {"version": CCM_VERSION}
458458
elif ccm_options is None:
459459
ccm_options = CCM_KWARGS.copy()
460460

461-
if 'version' in ccm_options and not isinstance(ccm_options['version'], Version):
462-
ccm_options['version'] = Version(ccm_options['version'])
463-
464461
cassandra_version = ccm_options.get('version', CCM_VERSION)
465462
dse_version = ccm_options.get('version', DSE_VERSION)
466463

467-
if 'version' in ccm_options:
468-
ccm_options['version'] = ccm_options['version'].base_version
469-
470464
global CCM_CLUSTER
471465
if USE_CASS_EXTERNAL:
472466
if CCM_CLUSTER:
@@ -515,12 +509,12 @@ def use_cluster(cluster_name, nodes, ipformat=None, start=True, workloads=None,
515509
CCM_CLUSTER = DseCluster(path, cluster_name, **ccm_options)
516510
CCM_CLUSTER.set_configuration_options({'start_native_transport': True})
517511
CCM_CLUSTER.set_configuration_options({'batch_size_warn_threshold_in_kb': 5})
518-
if dse_version >= Version('5.0'):
512+
if Version(dse_version) >= Version('5.0'):
519513
CCM_CLUSTER.set_configuration_options({'enable_user_defined_functions': True})
520514
CCM_CLUSTER.set_configuration_options({'enable_scripted_user_defined_functions': True})
521515
if 'spark' in workloads:
522516
config_options = {"initial_spark_worker_resources": 0.1}
523-
if dse_version >= Version('6.7'):
517+
if Version(dse_version) >= Version('6.7'):
524518
log.debug("Disabling AlwaysON SQL for a DSE 6.7 Cluster")
525519
config_options['alwayson_sql_options'] = {'enabled': False}
526520
CCM_CLUSTER.set_dse_configuration_options(config_options)
@@ -532,9 +526,9 @@ def use_cluster(cluster_name, nodes, ipformat=None, start=True, workloads=None,
532526
else:
533527
CCM_CLUSTER = CCMCluster(path, cluster_name, **ccm_options)
534528
CCM_CLUSTER.set_configuration_options({'start_native_transport': True})
535-
if cassandra_version >= Version('2.2'):
529+
if Version(cassandra_version) >= Version('2.2'):
536530
CCM_CLUSTER.set_configuration_options({'enable_user_defined_functions': True})
537-
if cassandra_version >= Version('3.0'):
531+
if Version(cassandra_version) >= Version('3.0'):
538532
CCM_CLUSTER.set_configuration_options({'enable_scripted_user_defined_functions': True})
539533
common.switch_cluster(path, cluster_name)
540534
CCM_CLUSTER.set_configuration_options(configuration_options)

0 commit comments

Comments
 (0)