diff --git a/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/BigQuerySqlClient/test_generate_uuid__plan0.sql b/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/BigQuerySqlClient/test_generate_uuid__plan0.sql new file mode 100644 index 0000000000..c5a3f8af0d --- /dev/null +++ b/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/BigQuerySqlClient/test_generate_uuid__plan0.sql @@ -0,0 +1,4 @@ +-- Test Generate UUID Expression +SELECT + GENERATE_UUID() AS uuid +FROM foo.bar a diff --git a/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/DatabricksSqlClient/test_generate_uuid__plan0.sql b/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/DatabricksSqlClient/test_generate_uuid__plan0.sql new file mode 100644 index 0000000000..4ec99ae030 --- /dev/null +++ b/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/DatabricksSqlClient/test_generate_uuid__plan0.sql @@ -0,0 +1,4 @@ +-- Test Generate UUID Expression +SELECT + UUID() AS uuid +FROM foo.bar a diff --git a/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/DuckDbSqlClient/test_generate_uuid__plan0.sql b/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/DuckDbSqlClient/test_generate_uuid__plan0.sql new file mode 100644 index 0000000000..2905cc51b1 --- /dev/null +++ b/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/DuckDbSqlClient/test_generate_uuid__plan0.sql @@ -0,0 +1,4 @@ +-- Test Generate UUID Expression +SELECT + GEN_RANDOM_UUID() AS uuid +FROM foo.bar a diff --git a/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/PostgresSqlClient/test_generate_uuid__plan0.sql b/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/PostgresSqlClient/test_generate_uuid__plan0.sql new file mode 100644 index 0000000000..2905cc51b1 --- /dev/null +++ b/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/PostgresSqlClient/test_generate_uuid__plan0.sql @@ -0,0 +1,4 @@ +-- Test Generate UUID Expression +SELECT + GEN_RANDOM_UUID() AS uuid +FROM foo.bar a diff --git a/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/RedshiftSqlClient/test_generate_uuid__plan0.sql b/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/RedshiftSqlClient/test_generate_uuid__plan0.sql new file mode 100644 index 0000000000..2bee48ccaf --- /dev/null +++ b/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/RedshiftSqlClient/test_generate_uuid__plan0.sql @@ -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 diff --git a/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/SnowflakeSqlClient/test_generate_uuid__plan0.sql b/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/SnowflakeSqlClient/test_generate_uuid__plan0.sql new file mode 100644 index 0000000000..72195d45ae --- /dev/null +++ b/metricflow/test/snapshots/test_engine_specific_rendering.py/SqlQueryPlan/SnowflakeSqlClient/test_generate_uuid__plan0.sql @@ -0,0 +1,4 @@ +-- Test Generate UUID Expression +SELECT + UUID_STRING() AS uuid +FROM foo.bar a diff --git a/metricflow/test/sql/test_engine_specific_rendering.py b/metricflow/test/sql/test_engine_specific_rendering.py index afde0f7371..ff6300a375 100644 --- a/metricflow/test/sql/test_engine_specific_rendering.py +++ b/metricflow/test/sql/test_engine_specific_rendering.py @@ -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 ( @@ -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 @@ -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, + )