Repository: sqlfluff/sqlfluff
Issue category: Bug Report

Boolean mistakingly treated as literal in ORDER BY clause
### Search before asking

- [X] I searched the [issues](https://github.com/sqlfluff/sqlfluff/issues) and found no similar issues.


### What Happened

Booleans are treated as literals in ORDER BY clause in this simple query:
```sql
SELECT 
      t.id
    , TRUE AS test
FROM mytable t
ORDER BY TRUE
```

### Expected Behaviour

TRUE should be treated as a boolean value

### Observed Behaviour

Running `sqlfluff lint -r RF03 my_sql_file.sql` returns the following errors:
```
L:   4 | P:  10 | RF03 | Unqualified reference 'TRUE' found in single table
                       | select. [references.consistent]
L:   4 | P:  10 | RF03 | Unqualified reference 'TRUE' found in single table
                       | select which is inconsistent with previous references.
                       | [references.consistent]
```


This is confirmed by the parsing result:
```
[L:  1, P:  1]      |file:
[L:  1, P:  1]      |    statement:
[L:  1, P:  1]      |        select_statement:
[L:  1, P:  1]      |            select_clause:
[L:  1, P:  1]      |                keyword:                                      'SELECT'
[L:  1, P:  7]      |                [META] indent:
[L:  1, P:  7]      |                whitespace:                                   ' '
[L:  1, P:  8]      |                select_clause_element:
[L:  1, P:  8]      |                    column_reference:
[L:  1, P:  8]      |                        naked_identifier:                     't'
[L:  1, P:  9]      |                        dot:                                  '.'
[L:  1, P: 10]      |                        naked_identifier:                     'id'
[L:  1, P: 12]      |                newline:                                      '\n'
[L:  2, P:  1]      |                whitespace:                                   '    '
[L:  2, P:  5]      |                comma:                                        ','
[L:  2, P:  6]      |                whitespace:                                   ' '
[L:  2, P:  7]      |                select_clause_element:
[L:  2, P:  7]      |                    boolean_literal:                          'TRUE'
[L:  2, P: 11]      |                    whitespace:                               ' '
[L:  2, P: 12]      |                    alias_expression:
[L:  2, P: 12]      |                        [META] indent:
[L:  2, P: 12]      |                        keyword:                              'AS'
[L:  2, P: 14]      |                        whitespace:                           ' '
[L:  2, P: 15]      |                        naked_identifier:                     'test'
[L:  2, P: 19]      |                        [META] dedent:
[L:  2, P: 19]      |                [META] dedent:
[L:  2, P: 19]      |            newline:                                          '\n'
[L:  3, P:  1]      |            from_clause:
[L:  3, P:  1]      |                keyword:                                      'FROM'
[L:  3, P:  5]      |                whitespace:                                   ' '
[L:  3, P:  6]      |                from_expression:
[L:  3, P:  6]      |                    [META] indent:
[L:  3, P:  6]      |                    from_expression_element:
[L:  3, P:  6]      |                        table_expression:
[L:  3, P:  6]      |                            table_reference:
[L:  3, P:  6]      |                                naked_identifier:             'mytable'
[L:  3, P: 13]      |                        whitespace:                           ' '
[L:  3, P: 14]      |                        alias_expression:
[L:  3, P: 14]      |                            [META] indent:
[L:  3, P: 14]      |                            naked_identifier:                 't'
[L:  3, P: 15]      |                            [META] dedent:
[L:  3, P: 15]      |                    [META] dedent:
[L:  3, P: 15]      |            newline:                                          '\n'
[L:  4, P:  1]      |            orderby_clause:
[L:  4, P:  1]      |                keyword:                                      'ORDER'
[L:  4, P:  6]      |                whitespace:                                   ' '
[L:  4, P:  7]      |                keyword:                                      'BY'
[L:  4, P:  9]      |                [META] indent:
[L:  4, P:  9]      |                whitespace:                                   ' '
[L:  4, P: 10]      |                column_reference:
[L:  4, P: 10]      |                    naked_identifier:                         'TRUE'
[L:  4, P: 14]      |                [META] dedent:
[L:  4, P: 14]      |    newline:                                                  '\n'
[L:  5, P:  1]      |    newline:                                                  '\n'
[L:  6, P:  1]      |    [META] end_of_file:
```

### How to reproduce

Run `sqlfluff lint -r RF03 my_sql_file.sql` on the following query:
```sql
SELECT t.id
    , TRUE AS test
FROM mytable t
ORDER BY TRUE
```


### Dialect

snowflake

### Version

sqlfluff version: 3.2.5
python version: 3.11.6

### Configuration

[sqlfluff]
dialect = snowflake
rules = RF03


### Are you willing to work on and submit a PR to address the issue?

- [ ] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/sqlfluff/sqlfluff/blob/main/CODE_OF_CONDUCT.md)



Functions to edit:
src/sqlfluff/dialects/dialect_snowflake.py:OrderByClauseSegment

Patch:
diff --git a/src/sqlfluff/dialects/dialect_snowflake.py b/src/sqlfluff/dialects/dialect_snowflake.py
index dd971228ff0..28c9fea30d1 100644
--- a/src/sqlfluff/dialects/dialect_snowflake.py
+++ b/src/sqlfluff/dialects/dialect_snowflake.py
@@ -7933,6 +7933,7 @@ class OrderByClauseSegment(ansi.OrderByClauseSegment):
         Delimited(
             Sequence(
                 OneOf(
+                    Ref("BooleanLiteralGrammar"),
                     Ref("ColumnReferenceSegment"),
                     # Can `ORDER BY 1`
                     Ref("NumericLiteralSegment"),

Test patch: diff --git a/test/fixtures/dialects/snowflake/select.sql b/test/fixtures/dialects/snowflake/select.sql
index 5c076da581c..37cc5ea5a8e 100644
--- a/test/fixtures/dialects/snowflake/select.sql
+++ b/test/fixtures/dialects/snowflake/select.sql
@@ -20,3 +20,11 @@ select notify from foo;
 select
     coalesce(do.a, do.b) as value
 from delivery_override as do
+;
+
+SELECT
+      t.id
+    , TRUE AS test
+FROM mytable t
+ORDER BY TRUE
+;
diff --git a/test/fixtures/dialects/snowflake/select.yml b/test/fixtures/dialects/snowflake/select.yml
index 6d570aa2bf6..8fd28c45d2d 100644
--- a/test/fixtures/dialects/snowflake/select.yml
+++ b/test/fixtures/dialects/snowflake/select.yml
@@ -3,7 +3,7 @@
 # computed by SQLFluff when running the tests. Please run
 # `python test/generate_parse_fixture_yml.py`  to generate them after adding or
 # altering SQL files.
-_hash: e04cf674461ae0533dfd32e6e7e16a4c4247b41edc11efd7b3e51c75b4be42af
+_hash: bf47c096b83f3a1a7e3107f5b90f7767e0a717db8b8ae79914887140f6b173a9
 file:
 - statement:
     select_statement:
@@ -171,3 +171,33 @@ file:
             alias_expression:
               keyword: as
               naked_identifier: do
+- statement_terminator: ;
+- statement:
+    select_statement:
+      select_clause:
+      - keyword: SELECT
+      - select_clause_element:
+          column_reference:
+          - naked_identifier: t
+          - dot: .
+          - naked_identifier: id
+      - comma: ','
+      - select_clause_element:
+          boolean_literal: 'TRUE'
+          alias_expression:
+            keyword: AS
+            naked_identifier: test
+      from_clause:
+        keyword: FROM
+        from_expression:
+          from_expression_element:
+            table_expression:
+              table_reference:
+                naked_identifier: mytable
+            alias_expression:
+              naked_identifier: t
+      orderby_clause:
+      - keyword: ORDER
+      - keyword: BY
+      - boolean_literal: 'TRUE'
+- statement_terminator: ;