Skip to content

Commit

Permalink
Merge branch 'master' into fix-347
Browse files Browse the repository at this point in the history
  • Loading branch information
chicco785 committed Sep 25, 2020
2 parents 5be2a2d + 1d062db commit ed36f36
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ QuantumLeap supports both Crate DB and Timescale as time-series DB
backends but please bear in mind that at the moment we only support
the following versions:

* Crate backend: Crate DB version `3.3.*` and `4.*` (experimental)
* Crate backend: Crate DB version `3.3.*` (will be deprecated from QL `0.8` version) and `4.*`
* Timescale backend: Postgres version `10.*` or `11.*` +
Timescale extension `1.3.*` + Postgis extension `2.5.*`.

Expand Down
18 changes: 16 additions & 2 deletions src/translators/crate.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
NGSI_TO_SQL = {
"Array": CRATE_ARRAY_STR, # TODO #36: Support numeric arrays
"Boolean": 'boolean',
# TODO since CRATEDB 4.0 timestamp is deprecated. Should be replaced with timestampz
# This means that to maintain both version, we will need a different mechanism
# TODO since CRATEDB 4.0 timestamp is deprecated,
# when moving to release 0.8, we will deprecate support for CRATE 3.x
# https://crate.io/docs/crate/reference/en/4.2/appendices/release-notes/4.0.0.html#general
NGSI_ISO8601: 'timestamp',
NGSI_DATETIME: 'timestamp',
"Integer": 'long',
Expand Down Expand Up @@ -59,6 +60,19 @@ def setup(self):
# and save few msec for evey API call
self.db_version = self.get_db_version()

major = int(self.db_version.split('.')[0])
if major <= 2:
logging.warning("CRATE 2.x support is deprecated")
elif major <= 3:
logging.warning("CRATE 3.x will be deprecated in release 0.8")
elif major >= 4:
NGSI_TO_SQL[NGSI_ISO8601] = 'timestamptz'
NGSI_TO_SQL[NGSI_DATETIME] = 'timestamptz'
NGSI_TO_SQL[TIME_INDEX] = 'timestamptz'
NGSI_TO_SQL["Integer"] = 'bigint'
NGSI_TO_SQL["Number"] = 'real'
NGSI_TO_SQL[NGSI_TEXT] = 'text'


def dispose(self):
self.cursor.close()
Expand Down

0 comments on commit ed36f36

Please sign in to comment.