Repository: googleapis/python-spanner

Issue:
float value cannot be used to insert data to NUMERIC field.
Float data type is mapped to float: spanner.param_types.FLOAT64 [Link](https://github.com/googleapis/python-spanner/blob/master/google/cloud/spanner_dbapi/parse_utils.py#L35).

We need to add support to map decimal.Decimal type in python to Numeric type in spanner.

#### Environment details

  - OS type and version: MacOS Big Sur 11.2.3
  - Python version: 3.8.8
  - pip version: pip 21.0.1
  - `google-cloud-spanner` version: 3.2.0

#### Steps to reproduce

  1. Create a table with Numeric field.
  2. Insert data in field with type float

#### Code example

```python
sql='INSERT INTO t (x) VALUES (%s)', 
params=[3.194387483193242e+19]
```

Thanks!


Discussion:

Patch:
diff --git a/google/cloud/spanner_dbapi/parse_utils.py b/google/cloud/spanner_dbapi/parse_utils.py
index 9ac6f3d..0a7d505 100644
--- a/google/cloud/spanner_dbapi/parse_utils.py
+++ b/google/cloud/spanner_dbapi/parse_utils.py
@@ -37,6 +37,7 @@ TYPES_MAP = {
     datetime.date: spanner.param_types.DATE,
     DateStr: spanner.param_types.DATE,
     TimestampStr: spanner.param_types.TIMESTAMP,
+    decimal.Decimal: spanner.param_types.NUMERIC,
 }
 
 SPANNER_RESERVED_KEYWORDS = {


Test patch:
diff --git a/tests/unit/spanner_dbapi/test_parse_utils.py b/tests/unit/spanner_dbapi/test_parse_utils.py
index c37c604..c612659 100644
--- a/tests/unit/spanner_dbapi/test_parse_utils.py
+++ b/tests/unit/spanner_dbapi/test_parse_utils.py
@@ -353,6 +353,7 @@ class TestParseUtils(unittest.TestCase):
     @unittest.skipIf(skip_condition, skip_message)
     def test_get_param_types(self):
         import datetime
+        import decimal
 
         from google.cloud.spanner_dbapi.parse_utils import DateStr
         from google.cloud.spanner_dbapi.parse_utils import TimestampStr
@@ -369,6 +370,7 @@ class TestParseUtils(unittest.TestCase):
             "h1": datetime.date(2011, 9, 1),
             "i1": b"bytes",
             "j1": None,
+            "k1": decimal.Decimal("3.194387483193242e+19"),
         }
         want_types = {
             "a1": param_types.INT64,
@@ -380,6 +382,7 @@ class TestParseUtils(unittest.TestCase):
             "g1": param_types.TIMESTAMP,
             "h1": param_types.DATE,
             "i1": param_types.BYTES,
+            "k1": param_types.NUMERIC,
         }
         got_types = get_param_types(params)
         self.assertEqual(got_types, want_types)