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

.NET: Thin 3.0: Nullable columns are not supported in KeyValueView with primitive mapping

    XMLWordPrintableJSON

Details

    Description

      The following test fails:

          [Test]
          public async Task TestPutGetNullable()
          {
              await Client.Sql.ExecuteAsync(null, "CREATE TABLE TestPutGetNullable (ID BIGINT PRIMARY KEY, VAL BIGINT)");
              await Client.Sql.ExecuteAsync(null, "INSERT INTO TestPutGetNullable VALUES (1, 1), (2, NULL)");
      
              var table = await Client.Tables.GetTableAsync("TestPutGetNullable");
              var view = table!.GetKeyValueView<long, long>();
      
              var res1 = await view.GetAsync(null, 1);
              var res2 = await view.GetAsync(null, 2);
          }
      

      Result:

      System.InvalidOperationException : Binary tuple element with index 1 is null.
         at Apache.Ignite.Internal.Proto.BinaryTuple.BinaryTupleReader.ThrowNullElementException[T](Int32 index) in /home/pavel/w/ignite-3/modules/platforms/dotnet/Apache.Ignite/Internal/Proto/BinaryTuple/BinaryTupleReader.cs:line 572
         at Apache.Ignite.Internal.Proto.BinaryTuple.BinaryTupleReader.GetLong(Int32 index) in /home/pavel/w/ignite-3/modules/platforms/dotnet/Apache.Ignite/Internal/Proto/BinaryTuple/BinaryTupleReader.cs:line 155
         at ReadApache.Ignite.Internal.Table.Serialization.KvPair`2[System.Int64,System.Int64](BinaryTupleReader& )
         at Apache.Ignite.Internal.Table.Serialization.ObjectSerializerHandler`1.Read(MsgPackReader& reader, Schema schema, Boolean keyOnly)
         at Apache.Ignite.Internal.Table.Serialization.RecordSerializer`1.ReadValue(PooledBuffer buf, Schema schema)
         at Apache.Ignite.Internal.Table.RecordView`1.GetAsync(ITransaction transaction, T key)
         at Apache.Ignite.Internal.Table.KeyValueView`2.GetAsync(ITransaction transaction, TK key)
         at Apache.Ignite.Tests.Table.KeyValueViewPrimitiveTests.TestPutGetNullable()
      

      ITable.GetKeyValueView does not allow nullable types ("where TV : notnull") - so we don't have a way to work with nullable columns in this case.
      See how Java handles this with additional nullable methods: IGNITE-16115

      Option<T> can represent 3 states to handle this situation:

      • hasValue=true, value != null
      • hasValue=true, value = null
      • hasValue=false

      Attachments

        Issue Links

          Activity

            People

              ptupitsyn Pavel Tupitsyn
              ptupitsyn Pavel Tupitsyn
              Igor Sapego Igor Sapego
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m