Repository: sqlfluff/sqlfluff

Issue:
EPOCH not recognized as a keyword
Hi, I'm using SQLFluff 0.3.6 with the Snowflake dialect and found that when I try to extract the epoch from a timestamp, I get an error about an unqualified reference, which leads me to believe that it's not recognizing the `EPOCH` keyword:

```
SELECT
  EXTRACT(EPOCH FROM t1.sometime) AS myepoch
FROM
  t1
INNER JOIN
  t2 ON t1.pk = t2.pk
```

gives:
```
L:   2 | P:  11 | L027 | Unqualified reference 'EPOCH' found in select with more
                       | than one referenced table/view.
```



Discussion:

Patch:
diff --git a/src/sqlfluff/core/dialects/dialect_postgres.py b/src/sqlfluff/core/dialects/dialect_postgres.py
index aac2b6b2c..096374afc 100644
--- a/src/sqlfluff/core/dialects/dialect_postgres.py
+++ b/src/sqlfluff/core/dialects/dialect_postgres.py
@@ -34,6 +34,8 @@ postgres_dialect.insert_lexer_struct(
 # Reserve WITHIN (required for the WithinGroupClauseSegment)
 postgres_dialect.sets("unreserved_keywords").remove("WITHIN")
 postgres_dialect.sets("reserved_keywords").add("WITHIN")
+# Add the EPOCH datetime unit
+postgres_dialect.sets("datetime_units").update(["EPOCH"])
 
 
 postgres_dialect.add(


Test patch:
diff --git a/test/core/dialects/postgres_test.py b/test/core/dialects/postgres_test.py
new file mode 100644
index 000000000..d7153b1a1
--- /dev/null
+++ b/test/core/dialects/postgres_test.py
@@ -0,0 +1,23 @@
+"""Tests specific to the postgres dialect."""
+
+import pytest
+
+from sqlfluff.core import FluffConfig, Linter
+
+
+@pytest.mark.parametrize(
+    "raw",
+    [
+        "SELECT t1.field, EXTRACT(EPOCH FROM t1.sometime) AS myepoch FROM t1",
+        "SELECT t1.field, EXTRACT(EPOCH FROM t1.sometime - t1.othertime) AS myepoch FROM t1",
+    ],
+)
+def test_epoch_datetime_unit(raw):
+    """Test the EPOCH keyword for postgres dialect."""
+    # Don't test for new lines or capitalisation
+    cfg = FluffConfig(
+        configs={"core": {"exclude_rules": "L009,L016", "dialect": "postgres"}}
+    )
+    lnt = Linter(config=cfg)
+    result = lnt.lint_string(raw)
+    assert result.num_violations() == 0
diff --git a/test/core/dialects/snowflake_test.py b/test/core/dialects/snowflake_test.py
index 2b7b6cba7..ccc9d2302 100644
--- a/test/core/dialects/snowflake_test.py
+++ b/test/core/dialects/snowflake_test.py
@@ -1,4 +1,4 @@
-"""Tests specific to the ansi dialect."""
+"""Tests specific to the snowflake dialect."""
 
 import pytest