Uploaded image for project: 'MongoDB ETL Tools'
  1. MongoDB ETL Tools
  2. TOOLS-1030

mongoexport / mongoimport: Getting a Double instead of a Integer

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Gone away
    • Affects Version/s: 3.0.7
    • Fix Version/s: None
    • Component/s: mongoexport, mongoimport
    • Labels:
      None
    • Environment:
      Linux version 3.2.0-4-amd64 (debian-kernel@lists.debian.org) (gcc version 4.6.3 (Debian 4.6.3-14) ) #1 SMP Debian 3.2.68-1+deb7u3

      mongoexport version: 3.0.0
      mongoimport version: 3.0.0

      Description

      Hi Team,

      After doing a mongoexport and mongoimport like the next:

      mongoexport -h $src -d xxx -c $src_collectioName | mongoimport -h $trgt -d xxx -c $trgt_collectionName

      I am getting a ClassCastException. Impossible to cast a Double into a Integer.

      I think the bug is the next:

      I have an array of Integer in the source mongodb. It's a list of ages with a name of "children_ages".

      After doing the command to export and import the data in another mongodb, I am getting the same list, but the type is converted to Double instead of Integer as expected.

      Example of real data using the $type to be sure the type of the array is correct:

      SourceDb:

      hi1:PRIMARY> db.price_stats_20151226.find({_id:ObjectId("567f10bb53d1e64bb1bede00"),children_ages:{$type:16}})

      { "_id" : ObjectId("567f10bb53d1e64bb1bede00"), "sp_id" : "41-16767", "s_id" : "41-40439", "kw" : [ "pricekw52x2015" ], "price_per_night" : 0, "total_price" : 430.75, "adults" : 1, "children_ages" : [ 1, 1, 4, 6, 12, 13 ], "number_of_days" : 1, "creation_date" : ISODate("2015-12-26T22:11:51.896Z"), "arrival_day" : ISODate("2015-12-25T23:00:00Z"), "departure_day" : ISODate("2015-12-26T23:00:00Z") }

      This is just one document under the collection "price_stats_20151226" with an array children_ages with a type:16, that it is Integer. In the sourceDB for the Id: 567f10bb53d1e64bb1bede00 the "children_ages" is : [ 1, 1, 4, 6, 12, 13 ]

      After exporting and importing the data i get

      Destination DB

      > db.price_stats.find({_id:ObjectId("567f10bb53d1e64bb1bede00"),children_ages:{$type:1}})

      { "_id" : ObjectId("567f10bb53d1e64bb1bede00"), "adults" : 1, "arrival_day" : ISODate("2015-12-25T23:00:00Z"), "children_ages" : [ 1, 1, 4, 6, 12, 13 ], "creation_date" : ISODate("2015-12-26T22:11:51.896Z"), "departure_day" : ISODate("2015-12-26T23:00:00Z"), "kw" : [ "pricekw52x2015" ], "number_of_days" : 1, "price_per_night" : 0, "s_id" : "41-40439", "sp_id" : "41-16767", "total_price" : 430.75 }

      I am getting all the data for the Id: 567f10bb53d1e64bb1bede00, but the array "children_ages" with the same data is converted to a Double array when i was expecting the same Integer Array.

      Then I am getting this ClassCastException in my java application.

      Regards from Munich,

      Manuel

        Attachments

          Activity

            People

            • Assignee:
              gabriel.russell Gabriel Russell
              Reporter:
              msierra msierra
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: