Repository: tobymao/sqlglot

Issue:
Postgres/Redshift - `FLOAT` is incorrectly interpreted as `REAL`
**Issue**
`FLOAT` in postgres and Redshift is equivalent to the double-precision floating point format. However, [KEYWORDS.FLOAT](https://github.com/tobymao/sqlglot/blob/main/sqlglot/tokens.py#L822) is interpreted as `REAL` instead of `DOUBLE` in the current implementation.

**Code to reproduce**
```python
from sqlglot import parse_one

postgres_ast = parse_one("cast(a AS FLOAT)", dialect="postgres")
print(postgres_ast.sql(dialect="postgres"))
#returns CAST(a AS REAL)
#expected assert(postgres_ast.sql(dialect="postgres") == "CAST(a AS DOUBLE PRECISION)")

redshift_ast = parse_one("cast(a AS FLOAT)", dialect="redshift")
print(redshift_ast.sql(dialect="redshift"))
#returns CAST(a AS REAL)
#expected assert(redshift_ast.sql(dialect="redshift") == "CAST(a AS DOUBLE PRECISION)")
```

**Official Documentation**
[Redshift - Floating-Point types](https://docs.aws.amazon.com/redshift/latest/dg/r_Numeric_types201.html#r_Numeric_types201-floating-point-types) - 
>DOUBLE PRECISION represents the double-precision floating point format, according to the IEEE Standard 754 for Binary Floating-Point Arithmetic. It has a precision of about 15 digits, and a range of around 1E-307 to 1E+308. You can also specify this data type as FLOAT or FLOAT8.

[Postgres - Floating point types](https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-FLOAT) - 
>float with no precision specified is taken to mean double precision.


Discussion:

Patch:
diff --git a/sqlglot/dialects/postgres.py b/sqlglot/dialects/postgres.py
index 433ad778..249a04ca 100644
--- a/sqlglot/dialects/postgres.py
+++ b/sqlglot/dialects/postgres.py
@@ -336,6 +336,7 @@ class Postgres(Dialect):
             "REGPROCEDURE": TokenType.OBJECT_IDENTIFIER,
             "REGROLE": TokenType.OBJECT_IDENTIFIER,
             "REGTYPE": TokenType.OBJECT_IDENTIFIER,
+            "FLOAT": TokenType.DOUBLE,
         }
 
         SINGLE_TOKENS = {


Test patch:
diff --git a/tests/dialects/test_postgres.py b/tests/dialects/test_postgres.py
index b1b6da0b..38c262fe 100644
--- a/tests/dialects/test_postgres.py
+++ b/tests/dialects/test_postgres.py
@@ -717,6 +717,9 @@ class TestPostgres(Validator):
         self.validate_identity(
             "COPY (SELECT * FROM t) TO 'file' WITH (FORMAT format, HEADER MATCH, FREEZE TRUE)"
         )
+        self.validate_identity("cast(a as FLOAT)", "CAST(a AS DOUBLE PRECISION)")
+        self.validate_identity("cast(a as FLOAT8)", "CAST(a AS DOUBLE PRECISION)")
+        self.validate_identity("cast(a as FLOAT4)", "CAST(a AS REAL)")
 
     def test_ddl(self):
         # Checks that user-defined types are parsed into DataType instead of Identifier