14.1. Creating a Storage (metastore.add_storage) #

Before creating an S3 storage, create a simple secret. You can create only one S3 storage.

Required privileges: Postgres Pro AXE administrator only. For a full list of stored procedures and privileges, refer to Section 12.1.

Execute the following command on the Postgres Pro AXE server:

  SELECT metastore.add_storage('storage_name', 'root_directory_URI', 'temporary_directory_URI') ON CONFLICT DO NOTHING;

Where:

  • storage_name: The unique storage name.

  • root_directory_URI: The URI of the root directory of the storage.

  • temporary_directory_URI: The URI of the temporary storage directory for Parquet files created by the metastore.copy_table stored procedure. This directory must exist before storage creation.

Local storages have simple URIs (e.g., file:///home/j.doe/workspace/axe/).

S3 storages have URIs with more complicated structures and parsing (e.g., s3://premdb/team01.csv?versionId=w_B5qT8s5MkiT09.IRHay0lW.PycsHTS). These URIs are generated using third-party libraries.

Postgres Pro AXE performs the following actions:

  1. Checks input parameters and user privileges.

  2. Ensures that there is enough free space for the storage. By default, 10 GB is required.

  3. Ensures that the specified directories exist.

  4. Creates a new entry in the pga_storage metadata table.

Example 14.1. Executing the metastore.add_storage Stored Procedure (Local Storage)

  SELECT metastore.add_storage('local_storage_example', 'file:///tmp/local_storage_example/', 'file:///tmp/local_storage_example/tmp_dir/') ON CONFLICT DO NOTHING;

Example 14.2. Executing the metastore.add_storage Stored Procedure (S3 Storage)

  SELECT metastore.add_storage('s3_storage_example', 's3://demo/s3_storage_example/','s3://demo/s3_storage_example/tmp/') ON CONFLICT DO NOTHING;

For an S3 storage connection scenario, refer to Section 30.2.