write_snowflake#

Dataset.write_snowflake(table: str, connection_parameters: Dict[str, Any], *, ray_remote_args: Dict[str, Any] | None = None, concurrency: int | None = None) → None[source]#

Write this Dataset to a Snowflake table.

Each write task loads its rows with write_pandas, which stages them as Parquet files and runs COPY INTO. If the table doesn’t exist, Snowflake creates it with column types inferred from the data. Otherwise, the rows are appended to it.

Note

This operation will trigger execution of the lazy transformations performed on this dataset.

Examples

>>> import ray
>>> connection_parameters = dict(
...     user=...,
...     account="ABCDEFG-ABC12345",
...     password=...,
...     database="SNOWFLAKE_SAMPLE_DATA",
...     schema="TPCDS_SF100TCL"
... )
>>> ds = ray.data.read_parquet("s3://anonymous@ray-example-data/iris.parquet")
>>> ds.write_snowflake("MY_DATABASE.MY_SCHEMA.IRIS", connection_parameters)
Parameters:
  • table (str) – The name of the table to write to, optionally qualified as schema.table or database.schema.table. Unquoted names aren’t case-sensitive, and double-quoted names are, as in Snowflake SQL. Column names are case-sensitive.

  • connection_parameters (Dict[str, Any]) – Keyword arguments to pass to snowflake.connector.connect. To view supported parameters, read https://docs.snowflake.com/developer-guide/python-connector/python-connector-api#functions.

  • ray_remote_args (Dict[str, Any] | None) – Keyword arguments passed to ray.remote() in the write tasks.

  • concurrency (int | None) – The maximum number of Ray tasks to run concurrently. Set this to control number of tasks to run concurrently. This doesn’t change the total number of tasks run. By default, concurrency is dynamically decided based on the available resources.