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

sec: BI-5958 bump snowflake-connector-python, fix MEDIAN in snowflake #772

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from dl_api_connector.api_schema.connection_base import ConnectionSchema
from dl_api_connector.api_schema.connection_base_fields import secret_string_field
from dl_api_connector.api_schema.connection_mixins import RawSQLLevelMixin
from dl_api_connector.api_schema.connection_sql import db_name_no_query_params
from dl_api_connector.api_schema.extras import FieldExtra

from dl_connector_snowflake.core.us_connection import ConnectionSQLSnowFlake
Expand Down Expand Up @@ -46,6 +47,7 @@ class SnowFlakeConnectionSchema(ConnectionSchema, RawSQLLevelMixin):
attribute="data.db_name",
required=True,
bi_extra=FieldExtra(editable=True),
validate=db_name_no_query_params,
)
warehouse = ma_fields.String(
attribute="data.warehouse",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class AggMedianDateSF(base.AggMedian):
sa.func.TO_TIMESTAMP(
within_group(
sa.func.PERCENTILE_DISC(0.5),
sa.func.DATE_PART("EPOCH_SECOND", expr.desc()),
sa.func.DATE_PART("EPOCH_SECOND", expr).desc(),
)
)
),
Expand All @@ -69,7 +69,7 @@ class AggMedianDateTimeSF(base.AggMedian):
lambda expr: sa.func.TO_TIMESTAMP(
within_group(
sa.func.PERCENTILE_DISC(0.5),
sa.func.DATE_PART("EPOCH_SECOND", expr.desc()),
sa.func.DATE_PART("EPOCH_SECOND", expr).desc(),
)
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ class TestSnowFlakeDataRange(SnowFlakeDataApiTestBase, DefaultConnectorDataRange


class TestSnowFlakeDataDistinct(SnowFlakeDataApiTestBase, DefaultConnectorDataDistinctTestSuite):
pass
test_params = RegulatedTestParams(
mark_tests_failed={
DefaultConnectorDataDistinctTestSuite.test_date_filter_distinct: "Requires db fixture, but it is not defined for Snowflake",
}
)


class TestSnowFlakeDataGroupBy(SnowFlakeDataApiTestBase, DefaultConnectorDataGroupByFormulaTestSuite):
Expand All @@ -37,3 +41,9 @@ class TestSnowFlakeDataPreview(SnowFlakeDataApiTestBase, DefaultConnectorDataPre

class TestSnowFlakeDataCache(SnowFlakeDataApiTestBase, DefaultConnectorDataCacheTestSuite):
data_caches_enabled = True

test_params = RegulatedTestParams(
mark_tests_failed={
DefaultConnectorDataCacheTestSuite.test_cache_with_filter_with_constants: "Requires db fixture, but it is not defined for Snowflake",
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ def test_connection_test(self, saved_connection, sync_conn_executor_factory) ->
with pytest.raises(SnowflakeGetAccessTokenError):
conn_executor.execute(ConnExecutorQuery(query="select 1"))

def test_connection_get_data_source_templates(self, saved_connection, sync_conn_executor_factory) -> None:
def sync_conn_executor_factory_for_conn(connection):
return sync_conn_executor_factory()

conn = saved_connection
with pytest.raises(SnowflakeGetAccessTokenError):
conn.get_data_source_templates(conn_executor_factory=sync_conn_executor_factory_for_conn)


class TestSnowFlakeConnectionWithRefreshTokenSoonToExpire(
TestSnowFlakeConnection,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import pytest as pytest

from dl_connector_snowflake_tests.ext.core.base import BaseSnowFlakeTestClass
from dl_connector_snowflake_tests.ext.core.base import SnowFlakeTestClassWithRefreshTokenSoonToExpire


class TestSnowflakeConnectionNotification(BaseSnowFlakeTestClass):
class TestSnowflakeConnectionNotification(SnowFlakeTestClassWithRefreshTokenSoonToExpire):
@pytest.mark.asyncio
async def test_refresh_token_notification_soon_to_expire(self, saved_connection_with_refresh_token_soon_to_expire):
notifications = saved_connection_with_refresh_token_soon_to_expire.check_for_notifications()
async def test_refresh_token_notification_soon_to_expire(self, saved_connection):
notifications = saved_connection.check_for_notifications()
record = notifications[0]
assert record.locator == "snowflake_refresh_token_soon_to_expire"
Loading