Repository: alanmcruickshank/sqlfluff

Issue:
Are functions not treated as keywords ?
Not an issue, more like a question. With
```
[sqlfluff:rules:L010]
capitalisation_policy = lower
```
using sqlfluff fix --rules L010 on
```sql
SELECT MAX(id) from table
```
becomes
```sql
select MAX(id) from table
```
Shouldn't `MAX` be also lower cased ?

Discussion:

Patch:
diff --git a/src/sqlfluff/rules/std.py b/src/sqlfluff/rules/std.py
index a11d1cd1..135be2a4 100644
--- a/src/sqlfluff/rules/std.py
+++ b/src/sqlfluff/rules/std.py
@@ -2101,3 +2101,18 @@ class Rule_L029(BaseCrawler):
             # Actually lint
             if segment.raw.upper() in dialect.sets('unreserved_keywords'):
                 return LintResult(anchor=segment)
+
+
+@std_rule_set.register
+class Rule_L030(Rule_L010):
+    """Inconsistent capitalisation of function names.
+
+    The functionality for this rule is inherited from :obj:`Rule_L010`.
+
+    Args:
+        capitalisation_policy (:obj:`str`): The capitalisation policy to
+            enforce. One of 'consistent', 'upper', 'lower', 'capitalise'.
+
+    """
+
+    _target_elems = (('name', 'function_name'),)


Test patch:
diff --git a/test/rules_std_test.py b/test/rules_std_test.py
index b4c81976..f3b66520 100644
--- a/test/rules_std_test.py
+++ b/test/rules_std_test.py
@@ -174,6 +174,10 @@ def assert_rule_pass_in_sql(code, sql, configs=None):
     ('L029', 'fail', 'SELECT 1 as parameter', None, None),
     ('L029', 'pass', 'SELECT parameter', None, None),  # should pass on default config as not alias
     ('L029', 'fail', 'SELECT parameter', None, {'rules': {'L029': {'only_aliases': False}}}),
+    # Inconsistent capitalisation of functions
+    ('L030', 'fail', 'SELECT MAX(id), min(id) from table', 'SELECT MAX(id), MIN(id) from table', None),
+    ('L030', 'fail', 'SELECT MAX(id), min(id) from table', 'SELECT max(id), min(id) from table',
+     {'rules': {'L030': {'capitalisation_policy': 'lower'}}})
 ])
 def test__rules__std_string(rule, pass_fail, qry, fixed, configs):
     """Test that a rule passes/fails on a given string.