Skip to content

Commit 4be0c80

Browse files
committed
test: make hive serde DDL test working with sqlfluff
1 parent 85b928f commit 4be0c80

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

sqllineage/core/parser/sqlparse/handlers/cte.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ def _handle(self, token: Token, holder: SubQueryLineageHolder) -> None:
2828
cte = []
2929
for token in cte:
3030
sublist = list(token.get_sublists())
31-
if sublist:
31+
if sublist and not (isinstance(sublist[0], Function)):
3232
# CTE: tbl AS (SELECT 1), tbl is alias and (SELECT 1) is subquery Parenthesis
3333
holder.add_cte(SqlParseSubQuery.of(sublist[0], token.get_real_name()))

tests/test_others_dialect_specific.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,19 @@ def test_create_table_as_with_postgres_dialect(dialect: str):
4040
)
4141

4242

43-
def test_create_using_serde():
43+
@pytest.mark.parametrize("dialect", ["databricks", "hive", "sparksql"])
44+
def test_create_using_serde(dialect: str):
4445
"""
4546
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-RowFormats&SerDe
4647
here with is not an indicator for CTE
47-
FIXME: sqlfluff hive dialect doesn't support parsing this yet
4848
"""
49-
# Check
50-
#
49+
# use raw sql string to avoid Python recognize some character as escaping
5150
assert_table_lineage_equal(
52-
"""CREATE TABLE apachelog (
51+
r"""CREATE TABLE apachelog (
5352
host STRING,
5453
identity STRING,
55-
user STRING,
56-
time STRING,
54+
`user` STRING,
55+
`time` STRING,
5756
request STRING,
5857
status STRING,
5958
size STRING,
@@ -66,7 +65,7 @@ def test_create_using_serde():
6665
STORED AS TEXTFILE""", # noqa
6766
None,
6867
{"apachelog"},
69-
test_sqlfluff=False,
68+
dialect=dialect,
7069
)
7170

7271

0 commit comments

Comments
 (0)