Repository: sqlfluff/sqlfluff

Issue:
Function dataset prefix keeps getting prepended
_If this is a parsing or linting issue, please include a minimal SQL example which reproduces the issue, along with the `sqlfluff parse` output, `sqlfluff lint` output and `sqlfluff fix` output when relevant._

## Expected Behaviour

The prefix should continue to occur once in the output.

## Observed Behaviour

The prefix seems to be prepended until the fix loop limit is reached.

## Steps to Reproduce

```console
$ printf 'SELECT project1.FOO(value) AS value\n' | sqlfluff fix -  
WARNING    Loop limit on fixes reached [10]. 
SELECT
    project1.PROJECT1.PROJECT1.PROJECT1.PROJECT1.PROJECT1.PROJECT1.PROJECT1.PROJECT1.PROJECT1.PROJECT1.FOO(
        value
    ) AS value
```

## Dialect

None specified

## Version
SQLFluff c3a1f703e6d34fd2b293ef17387fe603cf910b82, Python 3.9.6

## Configuration

None

Discussion:
alanmcruickshank: I think the complexity here is legacy from when `function_name_identifier` didn't exist, and we only had `function_name`. Assuming tests pass, I don't see why we can't merge this.
tunetheweb: But the rule depends on `function_name_identifer` existing 🤷‍♂️🤷‍♂️🤷‍♂️
tunetheweb: Maybe previous it got the identifier as a subset of `function_name` and when that was updated to `function_name_identifier` the rule was simply updated without realising it could be simplified at same time? 
tunetheweb: > Maybe previous it got the identifier as a subset of `function_name` and when that was updated to `function_name_identifier` the rule was simply updated without realising it could be simplified at same time?

Yeah think that was the case: https://github.com/sqlfluff/sqlfluff/commit/93c4702804a63da6b39a7b77ecdcf4f515dbe74a#

Anyway this seems good to merge now. Ignore the Circle CI error - needs to be turned off.

Patch:
diff --git a/src/sqlfluff/rules/L030.py b/src/sqlfluff/rules/L030.py
index 1c1ff765f..21603c7b7 100644
--- a/src/sqlfluff/rules/L030.py
+++ b/src/sqlfluff/rules/L030.py
@@ -2,7 +2,6 @@
 
 from typing import List, Tuple
 
-from sqlfluff.core.rules.base import LintFix
 from sqlfluff.core.rules.doc_decorators import (
     document_configuration,
     document_fix_compatible,
@@ -40,28 +39,10 @@ class Rule_L030(Rule_L010):
     """
 
     _target_elems: List[Tuple[str, str]] = [
-        ("type", "function_name"),
+        ("type", "function_name_identifier"),
         ("type", "bare_function"),
     ]
     _description_elem = "Function names"
 
     def _get_fix(self, segment, fixed_raw):
-        """Overrides the base class.
-
-        We need to do this because function_name nodes have a child
-        function_name_identifier that holds the actual name.
-        """
-        if segment.type == "function_name":
-
-            child_segment = [
-                child
-                for child in segment.segments
-                if child.get_type() == "function_name_identifier"
-            ][0]
-            return LintFix(
-                "edit",
-                child_segment,
-                child_segment.edit(fixed_raw.strip()),
-            )
-
         return super()._get_fix(segment, fixed_raw)


Test patch:
diff --git a/test/fixtures/rules/std_rule_cases/L030.yml b/test/fixtures/rules/std_rule_cases/L030.yml
index aad35080d..7c323b040 100644
--- a/test/fixtures/rules/std_rule_cases/L030.yml
+++ b/test/fixtures/rules/std_rule_cases/L030.yml
@@ -39,3 +39,11 @@ test_bare_functions_2:
 test_fail_capitalization_after_comma:
   fail_str: SELECT FLOOR(dt) ,count(*) FROM test
   fix_str: SELECT FLOOR(dt) ,COUNT(*) FROM test
+
+test_fail_fully_qualified_function_mixed_functions:
+  fail_str: SELECT COUNT(*), project1.foo(value1) AS value2
+  fix_str: SELECT COUNT(*), project1.FOO(value1) AS value2
+
+test_fail_fully_qualified_function_mixed_case:
+  fail_str: SELECT project1.FoO(value1) AS value2
+  fix_str: SELECT project1.FOO(value1) AS value2