Skip to content

Commit d7d6d35

Browse files
committed
IGNITE-11528: Deprecate SqlQuery API
This closes #11
1 parent 2c0ecb2 commit d7d6d35

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

pyignite/api/sql.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
"""
17-
Only key-value queries (scan queries) are implemented. SQL part is still
18-
in progress.
19-
"""
20-
2116
from typing import Union
2217

2318
from pyignite.constants import *
@@ -28,7 +23,7 @@
2823
from pyignite.datatypes.sql import StatementType
2924
from pyignite.queries import Query
3025
from pyignite.queries.op_codes import *
31-
from pyignite.utils import cache_id
26+
from pyignite.utils import cache_id, deprecated
3227
from .result import APIResult
3328

3429

@@ -142,6 +137,8 @@ def scan_cursor_get_page(
142137
return result
143138

144139

140+
@deprecated(version='1.2.0', reason="This API is deprecated and will be removed in the following major release. "
141+
"Use sql_fields instead")
145142
def sql(
146143
conn: 'Connection', cache: Union[str, int],
147144
table_name: str, query_str: str, page_size: int, query_args=None,
@@ -227,6 +224,8 @@ def sql(
227224
return result
228225

229226

227+
@deprecated(version='1.2.0', reason="This API is deprecated and will be removed in the following major release. "
228+
"Use sql_fields instead")
230229
def sql_cursor_get_page(
231230
conn: 'Connection', cursor: int, query_id: int = None,
232231
) -> APIResult:

pyignite/utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import ctypes
1717
import decimal
18+
import warnings
1819

1920
from functools import wraps
2021
from threading import Event, Thread
@@ -313,3 +314,13 @@ def process_delimiter(name: str, delimiter: str) -> str:
313314
Splits the name by delimiter, capitalize each part, merge.
314315
"""
315316
return ''.join([capitalize(x) for x in name.split(delimiter)])
317+
318+
319+
def deprecated(version, reason):
320+
def decorator_deprecated(fn):
321+
@wraps(fn)
322+
def wrapper_deprecated(*args, **kwds):
323+
warnings.warn(f'Deprecated since {version}. The reason: {reason}', category=DeprecationWarning)
324+
return fn(*args, **kwds)
325+
return wrapper_deprecated
326+
return decorator_deprecated

0 commit comments

Comments
 (0)