Skip to content

Commit

Permalink
added test and updated snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamDee committed Dec 7, 2022
1 parent b677a2b commit d9891c4
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Test Generate UUID Expression
SELECT
GENERATE_UUID() AS uuid
FROM foo.bar a
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Test Generate UUID Expression
SELECT
UUID() AS uuid
FROM foo.bar a
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Test Generate UUID Expression
SELECT
GEN_RANDOM_UUID() AS uuid
FROM foo.bar a
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Test Generate UUID Expression
SELECT
GEN_RANDOM_UUID() AS uuid
FROM foo.bar a
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Test Generate UUID Expression
SELECT
CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS uuid
FROM foo.bar a
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Test Generate UUID Expression
SELECT
UUID_STRING() AS uuid
FROM foo.bar a
37 changes: 35 additions & 2 deletions metricflow/test/sql/test_engine_specific_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from metricflow.protocols.sql_client import SqlClient
from metricflow.sql.sql_exprs import (
SqlCastToTimestampExpression,
SqlGenerateUuidExpression,
SqlStringLiteralExpression,
)
from metricflow.sql.sql_plan import (
Expand Down Expand Up @@ -36,8 +37,6 @@ def test_cast_to_timestamp(
]

from_source = SqlTableFromClauseNode(sql_table=SqlTable(schema_name="foo", table_name="bar"))

from_source = from_source
from_source_alias = "a"
joins_descs: List[SqlJoinDescription] = []
where = None
Expand All @@ -60,3 +59,37 @@ def test_cast_to_timestamp(
plan_id="plan0",
sql_client=sql_client,
)


def test_generate_uuid(
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
sql_client: SqlClient,
) -> None:
"""Tests rendering of the generate uuid expression in a query."""

select_columns = [
SqlSelectColumn(
expr=SqlGenerateUuidExpression(),
column_alias="uuid",
),
]
from_source = SqlTableFromClauseNode(sql_table=SqlTable(schema_name="foo", table_name="bar"))
from_source_alias = "a"

assert_rendered_sql_equal(
request=request,
mf_test_session_state=mf_test_session_state,
select_node=SqlSelectStatementNode(
description="Test Generate UUID Expression",
select_columns=tuple(select_columns),
from_source=from_source,
from_source_alias=from_source_alias,
joins_descs=(),
where=None,
group_bys=(),
order_bys=(),
),
plan_id="plan0",
sql_client=sql_client,
)

0 comments on commit d9891c4

Please sign in to comment.