Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mindsdb_sql_parser/__about__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__title__ = 'mindsdb_sql_parser'
__package_name__ = 'mindsdb_sql_parser'
__version__ = '0.0.2'
__version__ = '0.1.0'
__description__ = "Mindsdb SQL parser"
__email__ = "[email protected]"
__author__ = 'MindsDB Inc'
Expand Down
3 changes: 2 additions & 1 deletion mindsdb_sql_parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,8 @@ def join_tables(self, p):
condition=p.expr)

@_('from_table_aliased COMMA from_table_aliased',
'join_tables_implicit COMMA from_table_aliased')
'join_tables_implicit COMMA from_table_aliased',
'join_tables COMMA from_table_aliased')
def join_tables_implicit(self, p):
return Join(left=p[0],
right=p[2],
Expand Down
35 changes: 35 additions & 0 deletions tests/test_base_sql/test_select_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1201,3 +1201,38 @@ def test_window_function_mindsdb(self):
assert str(ast) == str(expected_ast)
assert ast.to_tree() == expected_ast.to_tree()

def test_mixed_join(self):

# modifier
query = '''
select * from table1 a
inner join table2 b on a.x = b.y
and k = p,
table3,
table4
'''
expected_ast = Select(
targets=[Star()],
from_table=Join(
left=Join(
left=Join(
left=Identifier('table1', alias=Identifier('a')),
right=Identifier('table2', alias=Identifier('b')),
condition=BinaryOperation(op='and', args=[
BinaryOperation(op='=', args=[Identifier('a.x'), Identifier('b.y')]),
BinaryOperation(op='=', args=[Identifier('k'), Identifier('p')])
]),
join_type=JoinType.INNER_JOIN,
),
right=Identifier('table3'),
join_type=JoinType.INNER_JOIN,
implicit=True
),
right=Identifier('table4'),
join_type=JoinType.INNER_JOIN,
implicit=True
)
)
ast = parse_sql(query)
assert str(ast) == str(expected_ast)
assert ast.to_tree() == expected_ast.to_tree()