mirror of
https://github.com/BillyOutlast/posthog.git
synced 2026-02-04 03:01:23 +01:00
fix: no None workloads + stacktrace if no workload is provided (#33080)
This commit is contained in:
@@ -192,7 +192,7 @@
|
||||
<partition_by>toYYYYMM(event_date)</partition_by>
|
||||
|
||||
<!-- Interval of flushing data. -->
|
||||
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
|
||||
<flush_interval_milliseconds>500</flush_interval_milliseconds>
|
||||
<!-- Maximal size in lines for the logs. When non-flushed logs amount reaches max_size, logs dumped to the disk. -->
|
||||
<max_size_rows>8388608</max_size_rows>
|
||||
<!-- Pre-allocated size in lines for the logs. -->
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import json
|
||||
import logging
|
||||
import threading
|
||||
import traceback
|
||||
import types
|
||||
from collections.abc import Sequence
|
||||
from contextlib import contextmanager
|
||||
@@ -99,6 +101,9 @@ def validated_client_query_id() -> Optional[str]:
|
||||
return f"{client_query_team_id}_{client_query_id}_{random_id}"
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@patchable
|
||||
def sync_execute(
|
||||
query,
|
||||
@@ -113,6 +118,10 @@ def sync_execute(
|
||||
sync_client: Optional[SyncClient] = None,
|
||||
ch_user: ClickHouseUser = ClickHouseUser.DEFAULT,
|
||||
):
|
||||
if not workload:
|
||||
workload = Workload.DEFAULT
|
||||
# TODO replace this by assert, sorry, no messing with ClickHouse should be possible
|
||||
logging.warning(f"workload is None", traceback.format_stack())
|
||||
if TEST and flush:
|
||||
try:
|
||||
from posthog.test.base import flush_persons_and_events
|
||||
@@ -315,7 +324,7 @@ def _prepare_query(
|
||||
return annotated_sql, prepared_args, tags
|
||||
|
||||
|
||||
def _annotate_tagged_query(query, workload):
|
||||
def _annotate_tagged_query(query, workload: Workload):
|
||||
"""
|
||||
Adds in a /* */ so we can look in clickhouses `system.query_log`
|
||||
to easily marry up to the generating code.
|
||||
|
||||
@@ -641,7 +641,7 @@ class QueryRunner(ABC, Generic[Q, R, CR]):
|
||||
modifiers: HogQLQueryModifiers
|
||||
limit_context: LimitContext
|
||||
is_query_service: bool = False
|
||||
workload: Optional[Workload] = None
|
||||
workload: Workload
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -651,7 +651,7 @@ class QueryRunner(ABC, Generic[Q, R, CR]):
|
||||
modifiers: Optional[HogQLQueryModifiers] = None,
|
||||
limit_context: Optional[LimitContext] = None,
|
||||
query_id: Optional[str] = None,
|
||||
workload: Optional[Workload] = None,
|
||||
workload: Workload = Workload.DEFAULT,
|
||||
extract_modifiers=lambda query: (query.modifiers if hasattr(query, "modifiers") else None),
|
||||
):
|
||||
self.team = team
|
||||
|
||||
Reference in New Issue
Block a user