Skip to content

Commit

Permalink
Change distinct behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
rad-pat committed Sep 16, 2024
1 parent 1cf8439 commit b7a21e8
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions plaidcloud/utilities/sql_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,24 +684,29 @@ def fill_in(var, var_name, default):

# Build DISTINCT section of our select query
if distinct:
select_query = select_query.distinct(
*[
get_from_clause(
tables,
tc,
source_columns,
aggregate,
variables=variables,
disable_variables=disable_variables,
table_numbering_start=table_numbering_start,
use_row_number_for_serial=use_row_number_for_serial,
)
for tc in target_columns
if not tc.get('constant')
and tc.get('distinct')
and (use_row_number_for_serial or not tc.get('dtype') in ('serial', 'bigserial'))
]
)
if any([tc for tc in target_columns if not tc.get('distinct')]):

Check warning on line 687 in plaidcloud/utilities/sql_expression.py

View workflow job for this annotation

GitHub Actions / PyLint

[PyLint] plaidcloud/utilities/sql_expression.py#L687

R1729: Use a generator instead 'any(tc for tc in target_columns if not tc.get('distinct'))' (use-a-generator)
Raw output
plaidcloud/utilities/sql_expression.py:687:11: R1729: Use a generator instead 'any(tc for tc in target_columns if not tc.get('distinct'))' (use-a-generator)
raise Exception('Distinct cannot be used if all columns are not distinct')

Check failure on line 688 in plaidcloud/utilities/sql_expression.py

View workflow job for this annotation

GitHub Actions / Lint PlaidCloud Utilities w ReviewDog

Distinct cannot be used if all columns are not distinct

Check failure on line 688 in plaidcloud/utilities/sql_expression.py

View workflow job for this annotation

GitHub Actions / Lint PlaidCloud Utilities w ReviewDog

Distinct cannot be used if all columns are not distinct

Check failure on line 688 in plaidcloud/utilities/sql_expression.py

View workflow job for this annotation

GitHub Actions / Lint PlaidCloud Utilities w ReviewDog

Distinct cannot be used if all columns are not distinct

Check failure on line 688 in plaidcloud/utilities/sql_expression.py

View workflow job for this annotation

GitHub Actions / Lint PlaidCloud Utilities w ReviewDog

Distinct cannot be used if all columns are not distinct

Check failure on line 688 in plaidcloud/utilities/sql_expression.py

View workflow job for this annotation

GitHub Actions / Lint PlaidCloud Utilities w ReviewDog

Distinct cannot be used if all columns are not distinct

Check warning on line 688 in plaidcloud/utilities/sql_expression.py

View workflow job for this annotation

GitHub Actions / PyLint

[PyLint] plaidcloud/utilities/sql_expression.py#L688

W0719: Raising too general exception: Exception (broad-exception-raised)
Raw output
plaidcloud/utilities/sql_expression.py:688:12: W0719: Raising too general exception: Exception (broad-exception-raised)
# every other database way
select_query = select_query.distinct()
# postgres way of doing distinct (*args) will become CompileError in future
# select_query = select_query.distinct(
# *[
# get_from_clause(
# tables,
# tc,
# source_columns,
# aggregate,
# variables=variables,
# disable_variables=disable_variables,
# table_numbering_start=table_numbering_start,
# use_row_number_for_serial=use_row_number_for_serial,
# )
# for tc in target_columns
# if not tc.get('constant')
# and tc.get('distinct')
# and (use_row_number_for_serial or not tc.get('dtype') in ('serial', 'bigserial'))
# ]
# )

# HAVING
if having:
Expand Down

0 comments on commit b7a21e8

Please sign in to comment.