snowflakedb / snowpark-python

Snowflake Snowpark Python API
Apache License 2.0
255 stars 106 forks source link

SNOW-1359450: Suport ASOF join #1484

Open sfc-gh-stan opened 4 months ago

sfc-gh-stan commented 4 months ago

ASOF join was introduced as preview feature in Snowpark Python API by https://github.com/snowflakedb/snowpark-python/pull/1254, we should port this into Local Testing path when the feature becomes generally available.

Reference: https://docs.snowflake.com/en/sql-reference/constructs/asof-join

sfc-gh-sghosh commented 4 months ago

Hello @sfc-gh-stan ,

Yes, currently keyword "ASOF" throwing error with local_testing, we are looking into it, will update.

`from snowflake.snowpark.types import StructType, StructField, TimestampType from snowflake.snowpark import Session import pandas as pd

session = Session.builder.config('local_testing', True).create()

print("local session created")

df1 = session.create_dataframe([['A', 1, 15, 3.21], ['A', 2, 16, 3.22], ['B', 1, 17, 3.23], ['B', 2, 18, 4.23]], schema=["c1", "c2", "c3", "c4"])

df2 = session.create_dataframe([['A', 1, 14, 3.19], ['B', 2, 16, 3.04]], schema=["c1", "c2", "c3", "c4"])

df1.join(df2, on=["c1", "c2"], how="asof", match_condition=(df1.c3 >= df2.c3)).select(df1.c1, df1.c2, df1.c3.alias("C3_1"), df1.c4.alias("C4_1"), df2.c3.alias("C3_2"), df2.c4.alias("C4_2")).order_by("c1", "c2").show() df1.show()`

Error: KeyError: 'asof'

Regards, Sujan