diff --git a/mindsdb_sql_parser/__about__.py b/mindsdb_sql_parser/__about__.py index 6d808bc..6a7aaec 100644 --- a/mindsdb_sql_parser/__about__.py +++ b/mindsdb_sql_parser/__about__.py @@ -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__ = "jorge@mindsdb.com" __author__ = 'MindsDB Inc' diff --git a/mindsdb_sql_parser/parser.py b/mindsdb_sql_parser/parser.py index 8dd87d8..55cec41 100644 --- a/mindsdb_sql_parser/parser.py +++ b/mindsdb_sql_parser/parser.py @@ -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], diff --git a/tests/test_base_sql/test_select_structure.py b/tests/test_base_sql/test_select_structure.py index 810dff6..d9acfc4 100644 --- a/tests/test_base_sql/test_select_structure.py +++ b/tests/test_base_sql/test_select_structure.py @@ -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()