ADS : 14-rc-42
Platform : Ubuntu 12.04 64 bit
MongoDB : 2.4.4
With reference to the attached dataset 'tde.csv', when it is imported into a mongo collection 'tde' (with 'stats' and 'weight' fields are of data types integer and double respectively) and following query is run, :
select * from tde where stats + weight > 1
no results are returned.
Expected results: At least 2 documents (those with stats = 89089980912 and weight = 789809080.8988789) should have been returned.
Could you please investigate? Thanks
![]() |
4 KB
The problem is not related to Import. You can also reproduce the problem by following these steps:
1. Create a record with int, long, and double values
insert into issue10334(int1, long2, double3, double4) values (150, 89089980912, 1340090880.7897, 789809080.8988789) go
2. The following queries work correctly.
select * from issue10334 where int1 > 1 go select * from issue10334 where long2 > 1 go select * from issue10334 where double3 > 1 go select * from issue10334 where double4 > 1 go select * from issue10334 where int1 + double3 > 1 go select * from issue10334 where double3 + double4 > 1 go
3. The following queries don't return any result. Note that the "long" field is used in the WHERE filter.
select * from issue10334 where int1 + long2 > 1 go select * from issue10334 where long2 + double3 > 1 go
Emil, please investigate and let us know what the problem is before applying the fix.
Emil, please investigate and let us know what the problem is before applying the fix.
@ravi - as part of your verification process, pls be sure to add an automated test case for this.
@ravi - as part of your verification process, pls be sure to add an automated test case for this.
These two queries fail to return any result due the typeof this['long2'] == 'number' javascript check we use to ensure that the given operand is a number (see issue #9725). It seems that this check doesn't work for 64-bit integers (the NumberLong instances) because their type is not 'number'.
Here are the MongoShell equivalents sent for these MongoSQL queries:
select * from issue10334 where int1 + long2 > 1
> db.issue10334.find({ "long2" : { "$exists" : true} , "int1" : { "$exists" : true} , "$where" : "(typeof this['long2']=='number') && (typeof this['int1']=='number') && (this['int1'] + this['long2']>1)"})
select * from issue10334 where long2 + double3 > 1
> db.issue10334.find({ "long2" : { "$exists" : true} , "double3" : { "$exists" : true} , "$where" : "(typeof this['long2']=='number') && (typeof this['double3']=='number') && (this['long2'] + this['double3']>1)"})
If I replace the (typeof this['long2'] == 'number') check with (typeof this['long2'] == 'number' || this['long2'] instanceof NumberLong) then I get the expected results:
> db.issue10334.find({ "long2" : { "$exists" : true} , "int1" : { "$exists" : true} , "$where" : "(typeof this['long2']=='number' || this['long2'] instanceof NumberLong) && (typeof this['int1']=='number' || this['int1'] instanceof NumberLong) && (this['int1'] + this['long2']>1)"})
> db.issue10334.find({ "long2" : { "$exists" : true} , "double3" : { "$exists" : true} , "$where" : "(typeof this['long2']=='number' || this['long2'] instanceof NumberLong) && (typeof this['double3']=='number' || this['double3'] instanceof NumberLong) && (this['long2'] + this['double3']>1)"})
These two queries fail to return any result due the typeof this['long2'] == 'number' javascript check we use to ensure that the given operand is a number (see issue #9725). It seems that this check doesn't work for 64-bit integers (the NumberLong instances) because their type is not 'number'.
Here are the MongoShell equivalents sent for these MongoSQL queries:
select * from issue10334 where int1 + long2 > 1
> db.issue10334.find({ "long2" : { "$exists" : true} , "int1" : { "$exists" : true} , "$where" : "(typeof this['long2']=='number') && (typeof this['int1']=='number') && (this['int1'] + this['long2']>1)"})
select * from issue10334 where long2 + double3 > 1
> db.issue10334.find({ "long2" : { "$exists" : true} , "double3" : { "$exists" : true} , "$where" : "(typeof this['long2']=='number') && (typeof this['double3']=='number') && (this['long2'] + this['double3']>1)"})
If I replace the (typeof this['long2'] == 'number') check with (typeof this['long2'] == 'number' || this['long2'] instanceof NumberLong) then I get the expected results:
> db.issue10334.find({ "long2" : { "$exists" : true} , "int1" : { "$exists" : true} , "$where" : "(typeof this['long2']=='number' || this['long2'] instanceof NumberLong) && (typeof this['int1']=='number' || this['int1'] instanceof NumberLong) && (this['int1'] + this['long2']>1)"})
> db.issue10334.find({ "long2" : { "$exists" : true} , "double3" : { "$exists" : true} , "$where" : "(typeof this['long2']=='number' || this['long2'] instanceof NumberLong) && (typeof this['double3']=='number' || this['double3'] instanceof NumberLong) && (this['long2'] + this['double3']>1)"})
@Ravi: can you add this to your test case, verify and close ?
@Ravi: can you add this to your test case, verify and close ?
Verified on ADS 14.0.1. Have forwarded test case to Jenny to be added to regression test suite.
Verified on ADS 14.0.1. Have forwarded test case to Jenny to be added to regression test suite.
Issue #10334 |
Closed |
Fixed |
Resolved |
Completion |
No due date |
Fixed Build ADS 14.0.0-2 (mongo-jdbc 1.3.8) |
No time estimate |
1 issue link |
relates to #10347
Issue #10347Different results returned for similar mongoSQL queries |
The problem is not related to Import. You can also reproduce the problem by following these steps:
1. Create a record with int, long, and double values
2. The following queries work correctly.
3. The following queries don't return any result. Note that the "long" field is used in the WHERE filter.