Skip to content

Commit

Permalink
fix(data-warehouse): add naming convention to url pattern (#25438)
Browse files Browse the repository at this point in the history
  • Loading branch information
EDsCODE authored Oct 7, 2024
1 parent cf0375c commit 129b279
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions posthog/temporal/tests/data_modeling/test_run_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from posthog.warehouse.models.table import DataWarehouseTable
from posthog.warehouse.models.modeling import DataWarehouseModelPath
from posthog.warehouse.util import database_sync_to_async
from dlt.common.normalizers.naming.snake_case import NamingConvention

pytestmark = [pytest.mark.asyncio, pytest.mark.django_db]

Expand Down Expand Up @@ -131,6 +132,7 @@ async def test_create_table_activity(activity_environment, ateam):

table = await DataWarehouseTable.objects.aget(name=saved_query.name)
assert table.name == saved_query.name
assert NamingConvention().normalize_identifier(saved_query.name) in table.url_pattern


@pytest.mark.parametrize(
Expand Down
6 changes: 3 additions & 3 deletions posthog/warehouse/models/datawarehouse_saved_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
)
from posthog.hogql.database.s3_table import S3Table
from posthog.warehouse.util import database_sync_to_async
from dlt.common.normalizers.naming.snake_case import NamingConvention


def validate_saved_query_name(value):
Expand Down Expand Up @@ -137,9 +138,8 @@ def folder_path(self):

@property
def url_pattern(self):
return (
f"https://{settings.AIRBYTE_BUCKET_DOMAIN}/dlt/team_{self.team.pk}_model_{self.id.hex}/modeling/{self.name}"
)
normalized_name = NamingConvention().normalize_identifier(self.name)
return f"https://{settings.AIRBYTE_BUCKET_DOMAIN}/dlt/team_{self.team.pk}_model_{self.id.hex}/modeling/{normalized_name}"

def hogql_definition(self, modifiers: Optional[HogQLQueryModifiers] = None) -> Union[SavedQuery, S3Table]:
from posthog.warehouse.models.table import CLICKHOUSE_HOGQL_MAPPING
Expand Down

0 comments on commit 129b279

Please sign in to comment.