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
```

Discussion:
codecov[bot]: # [Codecov](https://codecov.io/gh/ofek/pypinfo/pull/109?src=pr&el=h1) Report
> Merging [#109](https://codecov.io/gh/ofek/pypinfo/pull/109?src=pr&el=desc) (8bb1e36) into [master](https://codecov.io/gh/ofek/pypinfo/commit/0007c10256804650b4787a14a32e38e8f9347bbc?el=desc) (0007c10) will **not change** coverage.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/ofek/pypinfo/pull/109/graphs/tree.svg?width=650&height=150&src=pr&token=9O1JOLFuVD)](https://codecov.io/gh/ofek/pypinfo/pull/109?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master     #109   +/-   ##
=======================================
  Coverage   94.15%   94.15%           
=======================================
  Files           6        6           
  Lines         359      359           
  Branches       36       36           
=======================================
  Hits          338      338           
  Misses         12       12           
  Partials        9        9           
```


| [Impacted Files](https://codecov.io/gh/ofek/pypinfo/pull/109?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pypinfo/core.py](https://codecov.io/gh/ofek/pypinfo/pull/109/diff?src=pr&el=tree#diff-cHlwaW5mby9jb3JlLnB5) | `89.06% <100.00%> (ø)` | |
| [tests/test\_core.py](https://codecov.io/gh/ofek/pypinfo/pull/109/diff?src=pr&el=tree#diff-dGVzdHMvdGVzdF9jb3JlLnB5) | `100.00% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/ofek/pypinfo/pull/109?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/ofek/pypinfo/pull/109?src=pr&el=footer). Last update [0007c10...8bb1e36](https://codecov.io/gh/ofek/pypinfo/pull/109?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-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():