Skip to content

Commit ebbe419

Browse files
committed
3.0 upgrade guide
1 parent 6e6d3d8 commit ebbe419

1 file changed

Lines changed: 116 additions & 0 deletions

File tree

docs/upgrading.rst

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,122 @@ Upgrading
44
.. toctree::
55
:maxdepth: 1
66

7+
Upgrading to 3.0
8+
----------------
9+
Version 3.0 of the DataStax Python driver for Apache Cassandra
10+
adds support for Cassandra 3.0 while maintaining support for
11+
all earlier versions. In addition to substantial internal rework,
12+
there are several updates to the API that integrators will need
13+
to consider:
14+
15+
Default consistency is now ``LOCAL_QUORUM``
16+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17+
Previous value was ``ONE``. ``ONE`` (or ``LOCAL_ONE``) is still appropriate for
18+
many applications, but the new default was chosen to be least surprising for
19+
new users not specifying a consistency level.
20+
21+
Execution API Updates
22+
^^^^^^^^^^^^^^^^^^^^^
23+
Result return normalization
24+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
25+
`PYTHON-368 <https://datastax-oss.atlassian.net/browse/PYTHON-368>`_
26+
Previously results would be returned as a ``list`` of rows for result rows
27+
up to ``fetch_size``, and ``PagedResult`` afterward. This could break
28+
application code that assumed one type and got another.
29+
30+
Now, all results are returned as an iterable :class:`~.ResultSet`.
31+
32+
The preferred way to consume results of unknown size is to iterate through
33+
them, letting automatic paging occur as they are consumed.
34+
35+
.. code-block:: python
36+
37+
results = session.execute("SELECT * FROM system.local")
38+
for row in results:
39+
process(row)
40+
41+
If the expected size of the results is known, it is still possible to
42+
materialize a list using the iterator:
43+
44+
.. code-block:: python
45+
46+
results = session.execute("SELECT * FROM system.local")
47+
row_list = list(results)
48+
49+
For backward compatability, :class:`~.ResultSet` supports indexing. If
50+
the result is paged, all pages will be materialized. A warning will
51+
be logged if a paged query is implicitly materialized.
52+
53+
Trace information is not attached to executed Statements
54+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55+
`PYTHON-318 <https://datastax-oss.atlassian.net/browse/PYTHON-318>`_
56+
Previously trace data was attached to Statements if tracing was enabled. This
57+
could lead to confusion if the same statement was used for multiple executions.
58+
59+
Now, trace data is associated with the ``ResponseFuture`` and ``ResultSet``
60+
returned for each query:
61+
62+
:meth:`.ResponseFuture.get_query_trace()`
63+
64+
:meth:`.ResponseFuture.get_all_query_traces()`
65+
66+
:meth:`.ResultSet.get_query_trace()`
67+
68+
:meth:`.ResultSet.get_all_query_traces()`
69+
70+
Binding named parameters now ignores extra names
71+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
72+
`PYTHON-178 <https://datastax-oss.atlassian.net/browse/PYTHON-178Cassadfasdf>`_
73+
Previously, :meth:`.BoundStatement.bind()` would raise if a mapping
74+
was passed with extra names not found in the prepared statement.
75+
76+
Behavior in 3.0+ is to ignore extra names.
77+
78+
blist removed as soft dependency
79+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
80+
`PYTHON-385 <https://datastax-oss.atlassian.net/browse/PYTHON-385>`_
81+
Previously the driver had a soft dependency on ``blist sortedset``, using
82+
that where available and using an internal fallback where possible.
83+
84+
Now, the driver never chooses the ``blist`` variant, instead returning the
85+
internal :class:`.util.SortedSet` for all ``set`` results. The class implements
86+
all standard set operations, so no integration code should need to change unless
87+
it explicitly checks for ``sortedset`` type.
88+
89+
Metadata API Updates
90+
^^^^^^^^^^^^^^^^^^^^
91+
`PYTHON-276 <https://datastax-oss.atlassian.net/browse/PYTHON-276>`_, `PYTHON-408 <https://datastax-oss.atlassian.net/browse/PYTHON-408>`_, `PYTHON-400 <https://datastax-oss.atlassian.net/browse/PYTHON-400>`_, `PYTHON-422 <https://datastax-oss.atlassian.net/browse/PYTHON-422>`_
92+
93+
Cassandra 3.0 brought a substantial overhaul to the internal schema metadata representation.
94+
This version of the driver supports that metadata in addition to the legacy version. Doing so
95+
also brought some changes to the metadata model.
96+
97+
The present API is documented: :any:`cassandra.metadata`. Changes highlighted below:
98+
99+
* All types are now exposed as CQL types instead of types derived from the internal server implementation
100+
* Some metadata attributes have changed names to match current nomenclature (for example, :attr:`.Index.kind` in place of ``Index.type``).
101+
* Some metadata attributes removed
102+
103+
* ``TableMetadata.keyspace`` reference replaced with :attr:`.TableMetadata.keyspace_name`
104+
* ``ColumnMetadata.index`` is removed table- and keyspace-level mappings are still maintained
105+
106+
Several deprecated features are removed
107+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
108+
`PYTHON-292 <https://datastax-oss.atlassian.net/browse/PYTHON-292>`_
109+
110+
* ``ResponseFuture.result`` timeout parameter is removed, use ``Session.execute`` timeout instead (`031ebb0 <https://github.com/datastax/python-driver/commit/031ebb0>`_)
111+
* ``Cluster.refresh_schema`` removed, use ``Cluster.refresh_*_metadata`` instead (`419fcdf <https://github.com/datastax/python-driver/commit/419fcdf>`_)
112+
* ``Cluster.submit_schema_refresh`` removed (`574266d <https://github.com/datastax/python-driver/commit/574266d>`_)
113+
* ``cqltypes`` time/date functions removed, use ``util`` entry points instead (`bb984ee <https://github.com/datastax/python-driver/commit/bb984ee>`_)
114+
* ``decoder`` module removed (`e16a073 <https://github.com/datastax/python-driver/commit/e16a073>`_)
115+
* ``TableMetadata.keyspace`` attribute replaced with ``keyspace_name`` (`cc94073 <https://github.com/datastax/python-driver/commit/cc94073>`_)
116+
* ``cqlengine.columns.TimeUUID.from_datetime`` removed, use ``util`` variant instead (`96489cc <https://github.com/datastax/python-driver/commit/96489cc>`_)
117+
* ``cqlengine.columns.Float(double_precision)`` parameter removed, use ``columns.Double`` instead (`a2d3a98 <https://github.com/datastax/python-driver/commit/a2d3a98>`_)
118+
* ``cqlengine`` keyspace management functions are removed in favor of the strategy-specific entry points (`4bd5909 <https://github.com/datastax/python-driver/commit/4bd5909>`_)
119+
* ``cqlengine.Model.__polymorphic_*__`` attributes removed, use ``__discriminator*`` attributes instead (`9d98c8e <https://github.com/datastax/python-driver/commit/9d98c8e>`_)
120+
* ``cqlengine.statements`` will no longer warn about list list prepend behavior (`79efe97 <https://github.com/datastax/python-driver/commit/79efe97>`_)
121+
122+
7123
Upgrading to 2.1 from 2.0
8124
-------------------------
9125
Version 2.1 of the DataStax Python driver for Apache Cassandra

0 commit comments

Comments
 (0)