Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method parser.columns_dict do not take into account subqueries. #528

Open
cmistiloglou opened this issue Oct 4, 2024 · 0 comments
Open

Comments

@cmistiloglou
Copy link

cmistiloglou commented Oct 4, 2024

I have the below sql query in MSSQL.

SELECT 
    ap.[AccountId], 
    (SELECT COUNT(*) FROM [Transactions] t WHERE t.[AccountId] = ap.[AccountId]) AS TransactionCount
FROM 
    [AccountProfiles] ap

I am using the Parser class and the columns_dict method contains the SELECT sql clause which do not take into account the subqueries.

parser = Parser(subquery)

tables = parser.tables
columns_dict = parser.columns_dict

As you can see from the sql query and the final output below in json format, in the Tables section registers the table from the subquery. In Select clause it does not contain the TransactionCount and it also takes the Where clause which is contained inside the subquery.

{
      "Tables": [
          "[Transactions]",
          "[AccountProfiles]"
      ],
      "Select": [
          "[AccountProfiles].[AccountId]"
      ],
      "Where": [
          "[Transactions].[AccountId]",
          "[AccountProfiles].[AccountId]",
          "*"
      ]
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants