.. _version_5.2.8:

=============
Version 5.2.8
=============

Released on 2023-05-09.

.. NOTE::

    If you are upgrading a cluster, you must be running CrateDB 4.0.2 or higher
    before you upgrade to 5.2.8.

    We recommend that you upgrade to the latest 5.1 release before moving to
    5.2.8.

    A rolling upgrade from 5.1.x to 5.2.8 is supported.
    Before upgrading, you should `back up your data`_.

.. WARNING::

    Tables that were created before CrateDB 4.x will not function with 5.x
    and must be recreated before moving to 5.x.x.

    You can recreate tables using ``COPY TO`` and ``COPY FROM`` or by
    `inserting the data into a new table`_.

.. _back up your data: https://crate.io/docs/crate/reference/en/latest/admin/snapshots.html
.. _inserting the data into a new table: https://crate.io/docs/crate/reference/en/latest/admin/system-information.html#tables-need-to-be-recreated



.. rubric:: Table of Contents

.. contents::
   :local:

See the :ref:`version_5.2.0` release notes for a full list of changes in the
5.2 series.

Fixes
=====

- Improved output representation of timestamp subtraction, by normalizing to
  bigger units, but no further than days, to be consistent with PostgreSQL
  behavior. e.g::

    SELECT '2022-12-05T11:22:33.123456789+05:30'::timestamp - '2022-12-03T11:22:33.123456789-02:15'::timestamp

  previously would return: ``PT40H15M`` and now returns: ``P1DT16H15M``.

- Improved error message for :ref:`date_bin <date-bin>` scalar function when the
  first argument of :ref:`INTERVAL data type <type-interval>` contains month
  and/or year units.

- Fixed an issue that caused ``AssertionError`` to be thrown when referencing
  previous relations, not explicitly joined, in an join condition, e.g.::

    SELECT * FROM t1
    CROSS JOIN t2
    INNER JOIN t3 ON t3.x = t1.x AND t3.y = t2

- Fixed an issue that caused ``DROP TABLE IF EXISTS`` to wrongly return ``1``
  row affected or ``SQLParseException`` (depending on user privileges), when
  called on an existent schema, a non-existent table and with the ``crate``
  catalog prefix, e.g.::

    DROP TABLE IF EXISTS crate.doc.non_existent_table

- Improved an optimization rule to enable index lookups instead of table scans
  in more cases. This is a follow up to a fix in 5.2.7 which fixed a regression
  introduced in 5.2.3.
