Join Dataframes from different DBs using Snowpark

Viewed 32

I am trying to join two tables/dataframes that come from different databases of snowflake, I am trying to do this using snowpark, not sql way(i.e., session.sql("")).

# Connecting to Database one
first_session = Session.builder.configs(connection_parameters).create()
# Connecting to Database Two
second_session = Session.builder.configs(connection_parameters).create()

table_one = first_session.table("table_one")
table_two = second_session.table("table_two")

result = table_two.join(
    table_one,
    (
        (table_two.col_x == table_one.col_x)
    ),
)


Error that shows up when above code is run - 

Object 'table_one' does not exist or not authorized
1 Answers

Simplest and best solution . Give fully qualified name for the tables. DB_NAME.SCHEMA_NAME.TABLE_NAME

And make sure the user you have logged in have access to both the objects.

Also I don't see a need to create two different sessions if both Your DBs are in same SF account.

Related