Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-9950

thin python: Decimal data type didn't match with others clients

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.7
    • 2.7
    • thin client
    • None
    • Ignite 2.7 latest sources
      default cache configuration
      Python 3.7
      nodejs 10+
      PHP 7.2+
      Ubuntu 17

    Description

      Trying to put Decimal value from JS or PHP client and get with Python, but exception throwing

      JS 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();
      

      Python get 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)))
      

      exception in python

      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'>]
      

      When trying with PHP have same exception

      Also when use Decimal from Python others clients return different value:

      Python decimal put 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)
      

      JS get

      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();
      

      JS return '141350' value
      PHP have same behavior as JS

      Attachments

        Issue Links

          Activity

            People

              Melnichuk Dmitry Melnichuk
              spilschikov Stepan Pilschikov
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: