Rob McInerney
08/13/2024, 5:10 PMDeepyaman Datta
08/13/2024, 5:59 PMDeepyaman Datta
08/13/2024, 6:00 PMRob McInerney
08/13/2024, 6:03 PMRob McInerney
08/13/2024, 6:03 PMRob McInerney
08/13/2024, 6:04 PMRob McInerney
08/13/2024, 6:05 PMDeepyaman Datta
08/13/2024, 6:05 PMQuick question - are Ibis tables and pandas dataframes interchangeable?You can convert back to pandas table (or Polars) as you need. The dataframe syntax is not the exact same, but it's familiar enough dataframe syntax.
Deepyaman Datta
08/13/2024, 6:05 PMOr rather, if I output an ibis table from a node, and use it as an input to another node that deals with it like a pandas dataframe, is that going to cause problems?You can use
to_pandas()
whenever you want to leave Snowflake context, and it'll materialize the data to pandas dataframeRob McInerney
08/13/2024, 6:05 PMRob McInerney
08/13/2024, 6:06 PMDeepyaman Datta
08/13/2024, 6:07 PMI.e., execution is happening in snowflake, and not loading the data locally?Correct
Rob McInerney
08/13/2024, 6:07 PMDeepyaman Datta
08/13/2024, 6:07 PMRob McInerney
08/13/2024, 6:08 PMRob McInerney
08/13/2024, 6:08 PMDeepyaman Datta
08/13/2024, 6:08 PMRob McInerney
08/13/2024, 6:08 PMRob McInerney
08/13/2024, 6:09 PMRob McInerney
08/13/2024, 6:09 PMDeepyaman Datta
08/13/2024, 6:40 PMRob McInerney
08/13/2024, 6:42 PMRob McInerney
08/13/2024, 6:43 PMRob McInerney
08/13/2024, 6:44 PMRob McInerney
08/13/2024, 6:44 PMRob McInerney
08/13/2024, 6:44 PMRob McInerney
08/13/2024, 6:45 PMRob McInerney
08/13/2024, 6:45 PMRob McInerney
08/13/2024, 6:45 PMDeepyaman Datta
08/13/2024, 6:46 PMibis.TableDataset
doesn't support credentials.yml
. You would need to pass it separately. You can use a resolver to "hide" it or load from environment.Deepyaman Datta
08/13/2024, 6:46 PMibis.TableDataset
doesn't support credentials.yml
(yet?) is because Ibis supports a number of backends, and no consistent way of passing credentials across all backends.)Rob McInerney
08/13/2024, 6:46 PMRob McInerney
08/13/2024, 6:47 PMDeepyaman Datta
08/13/2024, 6:48 PMconnection:
backend: snowflake
user: user
password: password
...
Rob McInerney
08/13/2024, 6:50 PMDeepyaman Datta
08/13/2024, 6:50 PMHow would i use a resolver?https://docs.kedro.org/en/stable/configuration/advanced_configuration.html#how-to-use-resolvers-in-the-omegaconfigloader also, you can see how to use env variable for credentials: https://docs.kedro.org/en/stable/configuration/advanced_configuration.html#how-to-load-credentials-through-environment-variables
Rob McInerney
08/13/2024, 6:58 PMRob McInerney
08/13/2024, 6:59 PMRob McInerney
08/13/2024, 7:00 PMRob McInerney
08/13/2024, 7:02 PMisochrones:
type: ibis.TableDataset
connection: ${_snowflake_prod_ibis}
table_name: DEMAND.LOCATIONS
isochrones:
type: ibis.TableDataset
connection: ${_snowflake_prod_ibis}
table_name: LOCATIONS
Where snowflake schema = “DEMAND” and snowflake table = “LOCATIONS”Rob McInerney
08/13/2024, 7:03 PMDeepyaman Datta
08/13/2024, 7:04 PMRob McInerney
08/13/2024, 7:04 PMlocations = con.table('LOCATIONS', database='DEMAND')
returns correct data, so I assume this is a config issueRob McInerney
08/13/2024, 7:04 PMRob McInerney
08/13/2024, 7:07 PMib_table = catalog.load('isochrones')
which is where it is failingDeepyaman Datta
08/13/2024, 7:12 PMHow did you createreturns correct data, so I assume this is a config issuelocations = con.table('LOCATIONS', database='DEMAND')
con
here? Can you share the code?Rob McInerney
08/13/2024, 7:12 PMDeepyaman Datta
08/13/2024, 7:13 PMdatabase
here is not "DEMAND", right?Rob McInerney
08/13/2024, 7:14 PMRob McInerney
08/13/2024, 7:14 PMRob McInerney
08/13/2024, 7:14 PMDeepyaman Datta
08/13/2024, 7:25 PMibis.TableDataset
doesn't support arguments to the underlying table
method, as you've pointed out. If this line were different, you could pass your argument: https://github.com/kedro-org/kedro-plugins/blob/main/kedro-datasets/kedro_datasets/ibis/table_dataset.py#L174
I can push an update for this. in the meantime, you can easily vendor the dataset yourself (see https://docs.kedro.org/en/stable/data/how_to_create_a_custom_dataset.html if you need guidance, or https://github.com/deepyaman/jaffle-shop/blob/main/src/jaffle_shop/datasets/ibis/table_dataset.py for an early version of the Ibis dataset before it was part of kedro-datasets
to see how this can be done), and add this functionality.Rob McInerney
08/13/2024, 7:26 PMRob McInerney
08/13/2024, 7:26 PMRob McInerney
08/13/2024, 7:27 PMRob McInerney
08/13/2024, 7:28 PMRob McInerney
08/13/2024, 7:29 PMUserWarning: Unable to create Ibis UDFs, some functionality will not work: 100132 (P0000): JavaScript execution error: Uncaught Execution
of multiple statements failed on statement "CREATE DATABASE IF NOT
EXISTS ..." (at line 1, position 0).
SQL access control error:
Insufficient privileges to operate on account ...
Rob McInerney
08/13/2024, 7:29 PMRob McInerney
08/13/2024, 7:29 PMDeepyaman Datta
08/13/2024, 7:30 PMRob McInerney
08/13/2024, 7:30 PMRob McInerney
08/13/2024, 7:30 PMDeepyaman Datta
08/13/2024, 7:30 PMcon = ibis.snowflake.connect(
user="user",
account="safpqpq-sq55555",
database="my_database/my_schema",
warehouse="my_warehouse",
authenticator="externalbrowser",
)
and that didn't work, right? Got the Ibis UDF error.Rob McInerney
08/13/2024, 7:30 PMDeepyaman Datta
08/13/2024, 7:31 PMWhat time zone are you in btw?US Mountain Time (Salt Lake City, UT)
Rob McInerney
08/13/2024, 7:31 PMDeepyaman Datta
08/13/2024, 8:52 PMcon = ibis.snowflake.connect(
user="user",
account="safpqpq-sq55555",
database="my_database",
schema="my_schema",
warehouse="my_warehouse",
authenticator="externalbrowser",
)
In that case, you should also be able to use the Ibis TableDataset
as is, by passing schema
in the connection config.
(Specifically, any of the input parameters in https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-api#label-snowflake-connector-methods should get passed under the hood from https://github.com/ibis-project/ibis/blob/9.3.0/ibis/backends/snowflake/__init__.py#L270)