Skip to content

Commit c557f96

Browse files
committed
tests
1 parent c0779f1 commit c557f96

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/test_mindsdb/test_views.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,24 @@ def test_alter_view_with_variables(self):
8282
assert str(ast) == str(expected_ast)
8383
assert ast.to_tree() == expected_ast.to_tree()
8484

85+
def test_create_view_with_using_clause(self):
86+
"""Test CREATE VIEW with USING clause"""
87+
sql = 'create view test_view as (select * from local_mysql.test_house where sqft = @myvar) using test = 1, params = {"x": "y"}'
88+
ast = parse_sql(sql)
89+
90+
assert ast.name.to_string() == 'test_view'
91+
assert ast.query_str == 'select * from local_mysql.test_house where sqft = @myvar'
92+
assert ast.using == {'test': 1, 'params': {'x': 'y'}}
93+
94+
def test_alter_view_with_using_clause(self):
95+
"""Test ALTER VIEW with USING clause"""
96+
sql = 'ALTER VIEW myview AS (select * from tbl) USING param1 = "value1", param2 = 123'
97+
ast = parse_sql(sql)
98+
99+
assert ast.name.to_string() == 'myview'
100+
assert ast.query_str == 'select * from tbl'
101+
assert ast.using == {'param1': 'value1', 'param2': 123}
102+
85103
# def test_create_dataset_full(self):
86104
# sql = "CREATE DATASET my_view FROM integr AS ( SELECT * FROM pred )"
87105
# ast = parse_sql(sql)

0 commit comments

Comments
 (0)