-
-
Notifications
You must be signed in to change notification settings - Fork 150
Open
Description
Describe the bug
I'm using .final()
but there are no changes in query.
Code:
query = AccountActualStatesGQ.get_query(info) # SQLAlchemy query
query = apply_requested_fields(info, query, AccountActualStates)
qs = query.filter_by(**kwargs)
qs = qs.final() <--
Then I'm compiling query:
logger.warning(f'Query to clickhouse: {qs.statement.compile(compile_kwargs={"literal_binds": True})}')
And got SELECT
query without FINAL.
SELECT account_actual_state.parsed_jetton_wallet_balance, account_actual_state.parsed_jetton_wallet_owner_address_address, account_actual_state.parsed_jetton_wallet_jetton_address_address, account_actual_state.parsed_jetton_wallet_data_is_approved, account_actual_state.address, account_actual_state.workchain, account_actual_state.gen_utime
FROM account_actual_state
WHERE account_actual_state.parsed_jetton_wallet_owner_address_address = '71050EEDE7F8CAD72DE92F3112C1D58860963267C68EB4AE8BCC45298258A81A' AND account_actual_state.parsed_jetton_wallet_jetton_address_address = 'F4BDD480FCD79D47DBAF6E037D1229115FEB2E7AC0F119E160EBD5D031ABDF2E' AND account_actual_state.parsed_jetton_wallet_data_is_approved = 1 ORDER BY account_actual_state.parsed_jetton_wallet_balance DESC
LIMIT 0, 150
I've quickly check debugger, it seems that Query class is from lib, but select statement in it not. When I call .final()
in query it works correctly (set final flag in class to True), but in sqlcompiler
final_clause = getattr(select, '_final_clause', None)
returns None
qs
Out[2]: <clickhouse_sqlalchemy.orm.query.Query at 0x169ad3e20>
qs.statement
Out[3]: <sqlalchemy.sql.selectable.Select object at 0x16a57c9d0>
I've also tried to catch _compile_context
call, but it seems that it's not calling. Maybe I do something wrong?
I've figured out that I can compile it in the right way:
context = qs._compile_context()
clause = context.query
try:
compiled = clause.compile(dialect=engine.dialect, compile_kwargs={"literal_binds": True,
"render_postcompile": True})
logger.warning(f'Query to clickhouse: {compiled}')
except Exception as e:
compiled = clause.compile(dialect=engine.dialect)
logger.warning(f'Query to clickhouse: {compiled}')
But actual query that will be sent to clickhouse (when iterate over qs
) will not contain FINAL
.
Versions
Latest version from git
Metadata
Metadata
Assignees
Labels
No labels