kayak / pypika

PyPika is a python SQL query builder that exposes the full richness of the SQL language using a syntax that reflects the resulting query. PyPika excels at all sorts of SQL queries but is especially useful for data analysis.
http://pypika.readthedocs.io/en/latest/
Apache License 2.0
2.43k stars 293 forks source link

Sub Queries and CTE not working on MS SQL Server Dialect #739

Open SawiSawaiz opened 11 months ago

SawiSawaiz commented 11 months ago

Sub queries and CTE currently do not work for MS SQL dialect.

Example for Subquery.


query_1 = MSSQLQuery().from_(Table("xyz")).select("a")
query_2 = MSSQLQuery().from_(query_1).select('*')
print(str(query_2))

This throws an error "get_sql() got multiple values for keyword argument 'groupby_alias'" However, it works if I do not use SQL Server Dialect.

similarly CTE also do not work Example for CTE

query_1 = MSSQLQuery().from_(Table("xyz")).select("a")
query_2 = MSSQLQuery().with_(query_1, "a").from_("a").select('*')
print(str(query_2))

This throws also throws an error "get_sql() got multiple values for keyword argument 'groupby_alias'"

wd60622 commented 5 months ago

Can you try without the () The from_ is a classmethod rather than a method