You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by is...@apache.org on 2021/02/04 15:41:48 UTC

[ignite-python-thin-client] 01/03: IGNITE-11528: Deprecate SqlQuery API

This is an automated email from the ASF dual-hosted git repository.

isapego pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite-python-thin-client.git

commit d7d6d35d906cebc2f69e63e18f6ae8b1abe76132
Author: Igor Sapego <ig...@gmail.com>
AuthorDate: Thu Feb 4 18:38:56 2021 +0300

    IGNITE-11528: Deprecate SqlQuery API
    
    This closes #11
---
 pyignite/api/sql.py | 11 +++++------
 pyignite/utils.py   | 11 +++++++++++
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/pyignite/api/sql.py b/pyignite/api/sql.py
index ebb3e30..73cacc6 100644
--- a/pyignite/api/sql.py
+++ b/pyignite/api/sql.py
@@ -13,11 +13,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-"""
-Only key-value queries (scan queries) are implemented. SQL part is still
-in progress.
-"""
-
 from typing import Union
 
 from pyignite.constants import *
@@ -28,7 +23,7 @@ from pyignite.datatypes import (
 from pyignite.datatypes.sql import StatementType
 from pyignite.queries import Query
 from pyignite.queries.op_codes import *
-from pyignite.utils import cache_id
+from pyignite.utils import cache_id, deprecated
 from .result import APIResult
 
 
@@ -142,6 +137,8 @@ def scan_cursor_get_page(
     return result
 
 
+@deprecated(version='1.2.0', reason="This API is deprecated and will be removed in the following major release. "
+                                    "Use sql_fields instead")
 def sql(
     conn: 'Connection', cache: Union[str, int],
     table_name: str, query_str: str, page_size: int, query_args=None,
@@ -227,6 +224,8 @@ def sql(
     return result
 
 
+@deprecated(version='1.2.0', reason="This API is deprecated and will be removed in the following major release. "
+                                    "Use sql_fields instead")
 def sql_cursor_get_page(
     conn: 'Connection', cursor: int, query_id: int = None,
 ) -> APIResult:
diff --git a/pyignite/utils.py b/pyignite/utils.py
index ce00d53..ef7b6f6 100644
--- a/pyignite/utils.py
+++ b/pyignite/utils.py
@@ -15,6 +15,7 @@
 
 import ctypes
 import decimal
+import warnings
 
 from functools import wraps
 from threading import Event, Thread
@@ -313,3 +314,13 @@ def process_delimiter(name: str, delimiter: str) -> str:
     Splits the name by delimiter, capitalize each part, merge.
     """
     return ''.join([capitalize(x) for x in name.split(delimiter)])
+
+
+def deprecated(version, reason):
+    def decorator_deprecated(fn):
+        @wraps(fn)
+        def wrapper_deprecated(*args, **kwds):
+            warnings.warn(f'Deprecated since {version}. The reason: {reason}', category=DeprecationWarning)
+            return fn(*args, **kwds)
+        return wrapper_deprecated
+    return decorator_deprecated