Repository: mabel-dev/opteryx

Issue:
🪲 remove semgrep
### Thank you for taking the time to report a problem with Opteryx.
_To help us to respond to your request we ask that you try to provide the below detail about the bug._

**Describe the bug** _A clear and specific description of what the bug is. What the error, incorrect or unexpected behaviour was._


**Expected behaviour** _A clear and concise description of what you expected to happen._


**Sample Code/Statement** _If you can, please submit the SQL statement or Python code snippet, or a representative example using the sample datasets._

~~~sql

~~~

**Additional context** _Add any other context about the problem here, for example what you have done to try to diagnose or workaround the problem._



Discussion:

Resolving patch:
diff --git a/opteryx/__init__.py b/opteryx/__init__.py
--- a/opteryx/__init__.py
+++ b/opteryx/__init__.py
@@ -37,7 +37,7 @@
 _env_path = Path(".") / ".env"
 
 #  deepcode ignore PythonSameEvalBinaryExpressiontrue: false +ve, values can be different
-if _env_path.exists() and (dotenv is None):  # pragma: no cover  # nosemgrep
+if _env_path.exists() and (dotenv is None):  # pragma: no cover
     # using a logger here will tie us in knots
     print(f"{datetime.datetime.now()} [LOADER] `.env` file exists but `dotEnv` not installed.")
 elif dotenv is not None:  # pragma: no cover variables from `.env`")
diff --git a/opteryx/functions/other_functions.py b/opteryx/functions/other_functions.py
--- a/opteryx/functions/other_functions.py
+++ b/opteryx/functions/other_functions.py
@@ -112,7 +112,7 @@ def iif(mask, true_values, false_values):
 def if_null(values, replacement):
     response = values
     for index, value in enumerate(values):
-        if value is None or value != value:  # nosec # nosemgrep
+        if value is None or value != value:  # nosec
             response[index] = replacement[index]
     return response
 
diff --git a/opteryx/third_party/pyarrow_ops/helpers.py b/opteryx/third_party/pyarrow_ops/helpers.py
--- a/opteryx/third_party/pyarrow_ops/helpers.py
+++ b/opteryx/third_party/pyarrow_ops/helpers.py
@@ -26,7 +26,7 @@ def _hash_value(val, nan=numpy.nan):
     if isinstance(val, (list, numpy.ndarray, tuple)):
         # XOR is faster however, x ^ x == y ^ y but x != y, so we don't use it
         return functools.reduce(lambda x, y: _hash_value(f"{y}:{x}", 0), val, APOLLO_11_DURATION)
-    if val != val or val is None:  # nosemgrep
+    if val != val or val is None:
         # nan is a float, but hash is an int, sometimes we need this to be an int
         return nan
     return hash(val)


Test patch:
diff --git a/tests/misc/perftest_inner_hash.py b/tests/misc/perftest_inner_hash.py
--- a/tests/misc/perftest_inner_hash.py
+++ b/tests/misc/perftest_inner_hash.py
@@ -19,7 +19,7 @@ def _hash_value(vals, nan=numpy.nan):
             ret.append(
                 functools.reduce(lambda x, y: _hash_value(f"{y}:{x}", 0), val, APOLLO_11_DURATION)
             )
-        elif val != val or val is None:  # nosemgrep
+        elif val != val or val is None:
             # nan is a float, but hash is an int, sometimes we need this to be an int
             ret.append(nan)
         else:
@@ -39,7 +39,7 @@ def _hash_value_new(vals, nan=numpy.nan):
             ret.append(CityHash64("".join(val.values())))
         elif isinstance(val, (list, tuple)):
             ret.append(CityHash64(numpy.array(val)))
-        elif val != val or val is None:  # nosemgrep
+        elif val != val or val is None:
             # nan is a float, but hash is an int, sometimes we need this to be an int
             ret.append(nan)
         else: