-
Type: Bug
-
Resolution: Fixed
-
Priority: Critical - P2
-
Affects Version/s: None
-
Component/s: None
-
Query Execution
-
Fully Compatible
-
ALL
-
v8.0, v7.3, v7.0, v6.0, v5.0
-
QE 2024-06-24, QE 2024-07-08
Summary
There may be a bug in {$log: [number, base]} when base is a fractional Decimal.
Repro Steps
Correct (expected) result with fractional float base:
>>> list(MongoClient()['test_django']['db_functions_floatmodel'].find()) [{'_id': ObjectId('6660745d51531296357f8fa9'), 'f1': 2.132, 'f2': 4.0}] >>> list(MongoClient()['test_django']['db_functions_floatmodel'].aggregate([{'$project': {'n_log': {'$log': ['$f2', '$f1']}}}])) [{'_id': ObjectId('66606e3fb4578f86aa1a4368'), 'n_log': 1.8311539825113472}]
Incorrect (actual) result with fractional decimal base:
>>> list(MongoClient()['test_django']['db_functions_decimalmodel'].find()) [{'_id': ObjectId('66606cd2b2969966cb92e387'), 'n1': Decimal128('2.132'), 'n2': Decimal128('4.0')}] >>> list(MongoClient()['test_django']['db_functions_decimalmodel'].aggregate([{'$project': {'n_log': {'$log': ['$n2', '$n1']}}}])) [{'_id': ObjectId('66606e3fb4578f86aa1a4367'), 'n_log': Decimal128('0.6502318766978849056446830407675202')}]
Correct result when base is a whole decimal:
>>> list(MongoClient()['test_django']['db_functions_decimalmodel'].find()) [{'_id': ObjectId('66606f3d95bcf86ba43bf81f'), 'n1': Decimal128('2'), 'n2': Decimal128('8')}] >>> list(MongoClient()['test_django']['db_functions_decimalmodel'].aggregate([{'$project': {'n_log': {'$log': ['$n2', '$n1']}}}])) [{'_id': ObjectId('66606f3d95bcf86ba43bf81f'), 'n_log': Decimal128('3')}]
Server Info:
{'version': '6.0.9', 'gitVersion': '90c65f9cc8fc4e6664a5848230abaa9b3f3b02f7', 'modules': ['enterprise'], 'allocator': 'system', 'javascriptEngine': 'mozjs', 'sysInfo': 'deprecated', 'versionArray': [6, 0, 9, 0], 'openssl': {'running': 'Apple Secure Transport'}, 'buildEnvironment': {'distmod': '', 'distarch': 'aarch64', 'cc': '/Applications/Xcode13.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang: Apple clang version 13.0.0 (clang-1300.0.29.30)', 'ccflags': '-Wno-error=unknown-warning-option -isysroot /Applications/Xcode13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -mmacosx-version-min=11.0 --target=darwin20.0.0 -arch arm64 -Werror -include mongo/platform/basic.h -ffp-contract=off -fasynchronous-unwind-tables -ggdb -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -fno-omit-frame-pointer -fno-strict-aliasing -O2 -Wno-unused-local-typedefs -Wno-unused-function -Wno-unused-private-field -Wno-deprecated-declarations -Wno-tautological-constant-out-of-range-compare -Wno-tautological-constant-compare -Wno-tautological-unsigned-zero-compare -Wno-tautological-unsigned-enum-zero-compare -Wno-unused-const-variable -Wno-missing-braces -Wno-inconsistent-missing-override -Wno-potentially-evaluated-expression -Wno-unused-lambda-capture -Wunguarded-availability -fstack-protector-strong -moutline-atomics', 'cxx': '/Applications/Xcode13.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++: Apple clang version 13.0.0 (clang-1300.0.29.30)', 'cxxflags': '-Werror=unused-result -Woverloaded-virtual -Wpessimizing-move -Wno-undefined-var-template -Wno-instantiation-after-specialization -fsized-deallocation -Wno-defaulted-function-deleted -Wunused-exception-parameter -stdlib=libc++ -std=c++17', 'linkflags': '-Wl,-syslibroot,/Applications/Xcode13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -mmacosx-version-min=11.0 --target=darwin20.0.0 -arch arm64 -Wl,-fatal_warnings -Wl,-bind_at_load -fstack-protector-strong -stdlib=libc++ -fdebug-types-section', 'target_arch': 'aarch64', 'target_os': 'macOS', 'cppdefines': 'SAFEINT_USE_INTRINSICS 0 PCRE_STATIC NDEBUG BOOST_THREAD_VERSION 5 BOOST_THREAD_USES_DATETIME BOOST_SYSTEM_NO_DEPRECATED BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS BOOST_ENABLE_ASSERT_DEBUG_HANDLER BOOST_LOG_NO_SHORTHAND_NAMES BOOST_LOG_USE_NATIVE_SYSLOG BOOST_LOG_WITHOUT_THREAD_ATTR ABSL_FORCE_ALIGNED_ACCESS'}, 'bits': 64, 'debug': False, 'maxBsonObjectSize': 16777216, 'macOS': {'osProductVersion': '14.5', 'osRelease': '23.5.0', 'version': 'Darwin Kernel Version 23.5.0: Wed May 1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000'}, 'storageEngines': ['devnull', 'ephemeralForTest', 'inMemory', 'queryable_wt', 'wiredTiger'], 'ok': 1.0}