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

Implicitly cast new column values to expected types on SQL UPDATE

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8
    • Fix Version/s: 1.8
    • Component/s: sql
    • Labels:
      None

      Description

      When the following query is run,

      update AllTypes set longCol = 1 where _key = ?
      

      it fails with exception

      Suppressed: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
      			at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing$RowDescriptor.wrap(IgniteH2Indexing.java:2960)
      			at org.apache.ignite.internal.processors.query.h2.opt.GridH2AbstractKeyValueRow.getValue(GridH2AbstractKeyValueRow.java:316)
      			at org.h2.index.BaseIndex.compareRows(BaseIndex.java:294)
      			at org.apache.ignite.internal.processors.query.h2.opt.GridH2TreeIndex$2.compare(GridH2TreeIndex.java:103)
      			at org.apache.ignite.internal.processors.query.h2.opt.GridH2TreeIndex$2.compare(GridH2TreeIndex.java:95)
      			at java.util.concurrent.ConcurrentSkipListMap$ComparableUsingComparator.compareTo(ConcurrentSkipListMap.java:647)
      			at java.util.concurrent.ConcurrentSkipListMap.findPredecessor(ConcurrentSkipListMap.java:727)
      			at java.util.concurrent.ConcurrentSkipListMap.doPut(ConcurrentSkipListMap.java:850)
      			at java.util.concurrent.ConcurrentSkipListMap.put(ConcurrentSkipListMap.java:1645)
      			at org.apache.ignite.internal.processors.query.h2.opt.GridH2TreeIndex.put(GridH2TreeIndex.java:362)
      			at org.apache.ignite.internal.processors.query.h2.opt.GridH2Table.doUpdate(GridH2Table.java:566)
      			at org.apache.ignite.internal.processors.query.h2.opt.GridH2Table.update(GridH2Table.java:495)
      			at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.store(IgniteH2Indexing.java:603)
      			at org.apache.ignite.internal.processors.query.GridQueryProcessor.store(GridQueryProcessor.java:737)
      			at org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager.store(GridCacheQueryManager.java:431)
      			at org.apache.ignite.internal.processors.cache.GridCacheMapEntry.updateIndex(GridCacheMapEntry.java:4019)
      			at org.apache.ignite.internal.processors.cache.GridCacheMapEntry.innerUpdate(GridCacheMapEntry.java:2458)
      			at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateSingle(GridDhtAtomicCache.java:2385)
      			at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal0(GridDhtAtomicCache.java:1787)
      

      It's due to that UPDATE's SELECT part selects 1 as int, and that's what we're setting to field. Problem can be solved by casting SELECTed values to the types that columns expect.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vozerov Vladimir Ozerov
                Reporter:
                al.psc Alexander Paschenko
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: