0

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
NikhilKV
  • 48
  • 6

1 Answers1

0

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.

  • Connection parameters require DB name and Schema name, as I have different DB's I am using different connections. Can you elaborate a little on using fully qualified names? If it is write a SQL query, I could use the fully qualified name, but I am not sure on how to put it in the python way of joining the tables. – NikhilKV Sep 09 '22 at 13:30
  • What I meant is, You can create a single connection with your user details and don't specify the optional DB and schema name there. So now u have a single session. Now double check if the user you have specified has access to both DB, schema and objects . Coz it seems a permission issue to me. Now use fully qualified name:- table_one = first_session.table("db_one.schema_one.table_one") table_two = second_session.table("db_two.schema_two.table_two"). . But do double check your accesses to the objects first. – Amlan Mishra Sep 16 '22 at 13:52