[ 
https://issues.apache.org/jira/browse/IGNITE-9950?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16658833#comment-16658833
 ] 

Dmitry Melnichuk commented on IGNITE-9950:
------------------------------------------

I already had some tests for the internal consistency of all datatypes' 
representation, including `Decimal`. Unfortunately, they did not help me to 
avoid this issue. (Though it did help to fix it, but that is another matter.)

The regressions of this kind can be detected only by interfacing with the 
reference client. I used Java client manually. TBH I have no idea of how to 
perform such tests automatically. Is it possible with our CI to launch Java and 
Python clients in sequence, against the same Ignite cluster?

> thin python: Decimal data type didn't match with others clients
> ---------------------------------------------------------------
>
>                 Key: IGNITE-9950
>                 URL: https://issues.apache.org/jira/browse/IGNITE-9950
>             Project: Ignite
>          Issue Type: Bug
>          Components: thin client
>    Affects Versions: 2.7
>         Environment: Ignite 2.7 latest sources
> default cache configuration
> Python 3.7
> nodejs 10+
> PHP 7.2+
> Ubuntu 17
>            Reporter: Stepan Pilschikov
>            Assignee: Dmitry Melnichuk
>            Priority: Major
>             Fix For: 2.7
>
>
> Trying to put Decimal value from JS or PHP client and get with Python, but 
> exception throwing
> JS code:
> {code}
> IgniteClient = require('apache-ignite-client');
> IgniteClientConfiguration = IgniteClient.IgniteClientConfiguration;
> const Decimal = IgniteClient.Decimal;
> const ObjectType = IgniteClient.ObjectType;
> ENDPOINT = '127.0.0.1:10800';
> igniteClient = new IgniteClient();
> async function start() {
>     await igniteClient.connect(new IgniteClientConfiguration(ENDPOINT));
>     try {
>         cache = (await igniteClient.getOrCreateCache("JS_DECIMAL"))
>                     .setKeyType(ObjectType.PRIMITIVE_TYPE.INTEGER)
>                     .setValueType(ObjectType.PRIMITIVE_TYPE.DECIMAL);
>         await cache.put(1, new Decimal('7.7'));
>     } finally {
>         igniteClient.disconnect();
>     }
> }
> start();
> {code}
> Python get code
> {code}
> from pyignite import Client
> from pyignite.datatypes import *
> client = Client()
> client.connect('127.0.0.1', 10800)
> cache = client.get_or_create_cache("JS_DECIMAL")
> print(str(cache.get(1, key_hint=IntObject)))
> {code}
> exception in python
> {code}
> Traceback (most recent call last):
>   File get_value_JS_DECIMAL.py", line 7, in <module>
>     print(str(cache.get(1, key_hint=IntObject)))
>   File "[ignite_src]/platforms/python/pyignite/utils.py", line 163, in 
> ste_wrapper
>     result = fn(*args, **kwargs)
>   File "[ignite_src]/platforms/python/pyignite/cache.py", line 200, in get
>     result = cache_get(self._client, self._cache_id, key, key_hint=key_hint)
>   File "[ignite_src]/platforms/python/pyignite/api/key_value.py", line 107, 
> in cache_get
>     ('value', AnyDataObject),
>   File "[ignite_src]/platforms/python/pyignite/queries/__init__.py", line 
> 291, in perform
>     result.value = response_struct.to_python(response)
>   File "[ignite_src]/platforms/python/pyignite/queries/__init__.py", line 96, 
> in to_python
>     *args, **kwargs
>   File "[ignite_src]/platforms/python/pyignite/datatypes/internal.py", line 
> 288, in to_python
>     return data_class.to_python(ctype_object)
>   File "[ignite_src]/platforms/python/pyignite/datatypes/standard.py", line 
> 183, in to_python
>     result = decimal.Decimal(data.decode(PROTOCOL_STRING_ENCODING))
> decimal.InvalidOperation: [<class 'decimal.ConversionSyntax'>]
> {code}
> When trying with PHP have same exception
> Also when use Decimal from Python others clients return different value:
> Python decimal put code
> {code} 
> from pyignite import Client
> from pyignite.datatypes import *
> from decimal import Decimal
> client = Client()
> client.connect('127.0.0.1', 10800)
> cache = client.get_or_create_cache("PY_DECIMAL")
> cache.put(1, Decimal('7.7'), key_hint=IntObject, value_hint=DecimalObject)
> {code}
> JS get
> {code}
> IgniteClient = require('apache-ignite-client');
> IgniteClientConfiguration = IgniteClient.IgniteClientConfiguration;
> const ObjectType = IgniteClient.ObjectType;
> ENDPOINT = '127.0.0.1:10800';
> igniteClient = new IgniteClient();
> async function start() {
>     await igniteClient.connect(new IgniteClientConfiguration(ENDPOINT));
>     try {
>         cache = (await igniteClient.getOrCreateCache("PY_DECIMAL"))
>                     .setKeyType(ObjectType.PRIMITIVE_TYPE.INTEGER);
>         console.log(await cache.get(1));
>     } finally {
>         igniteClient.disconnect();
>     }
> }
> start();
> {code}
> JS return '141350' value
> PHP have same behavior as JS



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to