---
# System prepended metadata

title: Snowpark - PI

---

# Snowpark - PI

```python
point_count = 100000
with session.query_history() as query_history:
    pi = (
        session.range(0, point_count)
            .select(
                uniform(
                    lit(-1.0).cast(FloatType()),
                    lit(1.0).cast(FloatType()),
                    random()
                ).alias("x"),
                uniform(
                    lit(-1.0).cast(FloatType()),
                    lit(1.0).cast(FloatType()),
                    random()
                ).alias("y"),
            )
            .filter(((col("x") * col("x")) + (col("y") * col("y"))) < 1)
            .select([(4 * count(lit("x"))) / point_count])
    )

    print()
    print(pi.first()[0])

for d in query_history.queries:
    print(d.sql_text)

with session.query_history() as query_history:
    pi = (
        session.range(0, point_count)
            .select(
                uniform(-1.0, 1.0, random()).alias("x"),
                uniform(-1.0, 1.0, random()).alias("y"),
            )
            .filter(((col("x") * col("x")) + (col("y") * col("y"))) < 1)
            .select([(4 * count(lit("x"))) / point_count])
    )

    print()
    print(pi.first()[0])
    

for d in query_history.queries:
    print(d.sql_text)
```

```sql
with d as (select -1.1 as a, -1.0 as b) 
select typeof(a), typeof(b) from d;
```
