Repository: reata/sqllineage

Issue:
Support postgres style type casts "keyword::TIMESTAMP"
Hi, thanks for your work, 

I got a `NoneType error` when use sql keywords within type as `keyword::TIMESTAMP`
such as:
```
sql1 = "select day from A " #no error
sql2 = "select day1::TIMESTAMP from A " #no error

sql3 = "select day::TIMESTAMP from A " #error
sql4 = "select clob::TIMESTAMP from A " #error
sql5 = "select class::TIMESTAMP from A " #error
```

if i use [keywords in sql](http://www.postgres.cn/docs/9.4/sql-keywords-appendix.html), it will cause a `NoneType error`:


`AttributeError: 'NoneType' object has no attribute 'strip'`

Discussion:
codecov[bot]: ## [Codecov](https://codecov.io/gh/reata/sqllineage/pull/367?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) Report
> Merging [#367](https://codecov.io/gh/reata/sqllineage/pull/367?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (ffdd46a) into [master](https://codecov.io/gh/reata/sqllineage/commit/e7b8e74b67e5cd1d704687869331f6dae93a4220?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (e7b8e74) will **increase** coverage by `0.00%`.
> The diff coverage is `100.00%`.

```diff
@@           Coverage Diff           @@
##           master     #367   +/-   ##
=======================================
  Coverage   99.38%   99.39%           
=======================================
  Files          42       42           
  Lines        1966     1972    +6     
=======================================
+ Hits         1954     1960    +6     
  Misses         12       12           
```


| [Impacted Files](https://codecov.io/gh/reata/sqllineage/pull/367?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | |
|---|---|---|
| [sqllineage/core/parser/sqlfluff/models.py](https://codecov.io/gh/reata/sqllineage/pull/367?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3FsbGluZWFnZS9jb3JlL3BhcnNlci9zcWxmbHVmZi9tb2RlbHMucHk=) | `100.00% <100.00%> (ø)` | |



Patch:
diff --git a/sqllineage/core/parser/sqlfluff/models.py b/sqllineage/core/parser/sqlfluff/models.py
index 2e52eaa..ecd4e4a 100644
--- a/sqllineage/core/parser/sqlfluff/models.py
+++ b/sqllineage/core/parser/sqlfluff/models.py
@@ -24,6 +24,7 @@ NON_IDENTIFIER_OR_COLUMN_SEGMENT_TYPE = [
     "when_clause",
     "else_clause",
     "select_clause_element",
+    "cast_expression",
 ]
 
 SOURCE_COLUMN_SEGMENT_TYPE = NON_IDENTIFIER_OR_COLUMN_SEGMENT_TYPE + [
@@ -113,7 +114,22 @@ class SqlFluffColumn(Column):
                 for sub_segment in sub_segments:
                     if sub_segment.type == "column_reference":
                         column_name = get_identifier(sub_segment)
-
+                    elif sub_segment.type == "expression":
+                        # special handling for postgres style type cast, col as target column name instead of col::type
+                        if len(sub2_segments := retrieve_segments(sub_segment)) == 1:
+                            if (
+                                sub2_segment := sub2_segments[0]
+                            ).type == "cast_expression":
+                                if (
+                                    len(
+                                        sub3_segments := retrieve_segments(sub2_segment)
+                                    )
+                                    == 2
+                                ):
+                                    if (
+                                        sub3_segment := sub3_segments[0]
+                                    ).type == "column_reference":
+                                        column_name = get_identifier(sub3_segment)
                 return Column(
                     column.raw if column_name is None else column_name,
                     source_columns=source_columns,


Test patch:
diff --git a/tests/test_columns.py b/tests/test_columns.py
index fcf0a59..d4bba13 100644
--- a/tests/test_columns.py
+++ b/tests/test_columns.py
@@ -734,6 +734,16 @@ SELECT cast('2012-12-21' AS date) AS col2"""
     assert_column_lineage_equal(sql)
 
 
+def test_postgres_style_type_cast():
+    sql = """INSERT INTO tab1
+SELECT col1::timestamp
+FROM tab2"""
+    assert_column_lineage_equal(
+        sql,
+        [(ColumnQualifierTuple("col1", "tab2"), ColumnQualifierTuple("col1", "tab1"))],
+    )
+
+
 def test_window_function_in_subquery():
     sql = """INSERT INTO tab1
 SELECT rn FROM (