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:47 UTC

[ignite-python-thin-client] branch master updated (2c0ecb2 -> 0f2828b)

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

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


    from 2c0ecb2  IGNITE-13863: Fix Null reading and writing
     new d7d6d35  IGNITE-11528: Deprecate SqlQuery API
     new 83208c2  IGNITE-12975: SQL query do not create cache
     new 0f2828b  IGNITE-14127: Default sql page size from 1 => 1024

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 pyignite/api/sql.py  | 11 +++++------
 pyignite/client.py   |  8 ++++----
 pyignite/utils.py    | 11 +++++++++++
 tests/test_binary.py |  1 +
 tests/test_sql.py    | 10 +++++++++-
 5 files changed, 30 insertions(+), 11 deletions(-)


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

Posted by is...@apache.org.
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


[ignite-python-thin-client] 03/03: IGNITE-14127: Default sql page size from 1 => 1024

Posted by is...@apache.org.
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 0f2828b521aa7bf93cfdcd5302bb77434fffe1e0
Author: Igor Sapego <ig...@gmail.com>
AuthorDate: Thu Feb 4 18:40:48 2021 +0300

    IGNITE-14127: Default sql page size from 1 => 1024
    
    This closes #13
---
 pyignite/client.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pyignite/client.py b/pyignite/client.py
index f8072d8..83cb196 100644
--- a/pyignite/client.py
+++ b/pyignite/client.py
@@ -519,7 +519,7 @@ class Client:
         return cache_get_names(self.random_node)
 
     def sql(
-        self, query_str: str, page_size: int = 1, query_args: Iterable = None,
+        self, query_str: str, page_size: int = 1024, query_args: Iterable = None,
         schema: Union[int, str] = 'PUBLIC',
         statement_type: int = 0, distributed_joins: bool = False,
         local: bool = False, replicated_only: bool = False,
@@ -531,8 +531,8 @@ class Client:
         Runs an SQL query and returns its result.
 
         :param query_str: SQL query string,
-        :param page_size: (optional) cursor page size. Default is 1, which
-         means that client makes one server call per row,
+        :param page_size: (optional) cursor page size. Default is 1024, which
+         means that client makes one server call per 1024 rows,
         :param query_args: (optional) query arguments. List of values or
          (value, type hint) tuples,
         :param schema: (optional) schema for the query. Defaults to `PUBLIC`,


[ignite-python-thin-client] 02/03: IGNITE-12975: SQL query do not create cache

Posted by is...@apache.org.
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 83208c2ef87d5b241c45dd5fd8f5ec4b58e2a8df
Author: Igor Sapego <ig...@gmail.com>
AuthorDate: Thu Feb 4 18:39:57 2021 +0300

    IGNITE-12975: SQL query do not create cache
    
    This closes #12
---
 pyignite/client.py   |  2 +-
 tests/test_binary.py |  1 +
 tests/test_sql.py    | 10 +++++++++-
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/pyignite/client.py b/pyignite/client.py
index 3202b78..f8072d8 100644
--- a/pyignite/client.py
+++ b/pyignite/client.py
@@ -586,7 +586,7 @@ class Client:
 
         conn = self.random_node
 
-        schema = self.get_or_create_cache(schema)
+        schema = self.get_cache(schema)
         result = sql_fields(
             conn, schema.cache_id, query_str,
             page_size, query_args, schema.name,
diff --git a/tests/test_binary.py b/tests/test_binary.py
index 46554ea..45d1d25 100644
--- a/tests/test_binary.py
+++ b/tests/test_binary.py
@@ -64,6 +64,7 @@ drop_query = 'DROP TABLE {} IF EXISTS'.format(table_sql_name)
 
 def test_sql_read_as_binary(client):
 
+    client.get_or_create_cache(scheme_name)
     client.sql(drop_query)
 
     # create table
diff --git a/tests/test_sql.py b/tests/test_sql.py
index 87383d3..15f84ee 100644
--- a/tests/test_sql.py
+++ b/tests/test_sql.py
@@ -13,12 +13,15 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import pytest
+
 from pyignite.api import (
     sql_fields, sql_fields_cursor_get_page,
-    cache_get_or_create, sql, sql_cursor_get_page,
+    sql, sql_cursor_get_page,
     cache_get_configuration,
 )
 from pyignite.datatypes.prop_codes import *
+from pyignite.exceptions import SQLError
 from pyignite.utils import entity_id, unwrap_binary
 
 initial_data = [
@@ -186,3 +189,8 @@ def test_long_multipage_query(client):
             assert value == field_number * page[0]
 
     client.sql(drop_query)
+
+
+def test_sql_not_create_cache(client):
+    with pytest.raises(SQLError, match=r".*Cache does not exist.*"):
+        client.sql(schema='IS_NOT_EXISTING', query_str='select * from IsNotExisting')