Repository: ofek/pypinfo

Issue:
No matching signature for function DATE_ADD for argument types: TIMESTAMP, INTERVAL INT64 DATE_TIME_PART
Hi,

After installation following instructions given in the `README.md`, I tried a simplest call:
```bash
pypinfo requests
```
Unfortunately getting following exception:
```
...
  File "/Users/christianr/.venv/sett/lib/python3.9/site-packages/pypinfo/cli.py", line 166, in pypinfo
    query_rows = query_job.result(timeout=timeout // 1000)
  File "/Users/christianr/.venv/sett/lib/python3.9/site-packages/google/cloud/bigquery/job/query.py", line 1160, in result
    super(QueryJob, self).result(retry=retry, timeout=timeout)
  File "/Users/christianr/.venv/sett/lib/python3.9/site-packages/google/cloud/bigquery/job/base.py", line 631, in result
    return super(_AsyncJob, self).result(timeout=timeout, **kwargs)
  File "/Users/christianr/.venv/sett/lib/python3.9/site-packages/google/api_core/future/polling.py", line 134, in result
    raise self._exception
google.api_core.exceptions.BadRequest: 400 No matching signature for function DATE_ADD for argument types: TIMESTAMP, INTERVAL INT64 DATE_TIME_PART. Supported signature: DATE_ADD(DATE, INTERVAL INT64 DATE_TIME_PART) at [5:25]

(job ID: 947e6084-e5e6-4bb5-ae12-bb8faad8ec0b)

                                                 -----Query Job SQL Follows-----

    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |
   1:SELECT
   2:  FORMAT_TIMESTAMP("%Y", timestamp) as download_year,
   3:  COUNT(*) as download_count,
   4:FROM `the-psf.pypi.file_downloads`
   5:WHERE timestamp BETWEEN DATE_ADD(CURRENT_TIMESTAMP(), INTERVAL -1826 DAY) AND DATE_ADD(CURRENT_TIMESTAMP(), INTERVAL -1 DAY)
   6:  AND file.project = "blist"
   7:  AND details.installer.name = "pip"
   8:GROUP BY
   9:  download_year
  10:ORDER BY
  11:  download_count DESC
  12:LIMIT 10
    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |

```
Using the SQL query in the **BigQuery** SQL workspace pops up the same error message if I use the _public PyPI download statistics dataset_.

My environment:
```
pypinfo, version 18.0.0
Python 3.9.1
```

Comments:

Patch:
diff --git a/pypinfo/core.py b/pypinfo/core.py
index 1075ea9..41bbd8c 100644
--- a/pypinfo/core.py
+++ b/pypinfo/core.py
@@ -10,7 +10,7 @@ from google.cloud.bigquery.job import QueryJobConfig
 from pypinfo.fields import AGGREGATES, Downloads
 
 FROM = 'FROM `the-psf.pypi.file_downloads`'
-DATE_ADD = 'DATE_ADD(CURRENT_TIMESTAMP(), INTERVAL {} DAY)'
+DATE_ADD = 'TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL {} DAY)'
 START_TIMESTAMP = 'TIMESTAMP("{} 00:00:00")'
 END_TIMESTAMP = 'TIMESTAMP("{} 23:59:59")'
 START_DATE = '-31'


Test patch:
diff --git a/tests/test_core.py b/tests/test_core.py
index 6965e5d..e873e91 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -88,7 +88,7 @@ def test_format_date_negative_number():
     date = core.format_date("-1", dummy_format)
 
     # Assert
-    assert date == 'DATE_ADD(CURRENT_TIMESTAMP(), INTERVAL -1 DAY)'
+    assert date == 'TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL -1 DAY)'
 
 
 def test_format_date_yyy_mm_dd():