|
| 1 | +==================== |
| 2 | +File-Based Metastore |
| 3 | +==================== |
| 4 | + |
| 5 | +.. contents:: |
| 6 | + :local: |
| 7 | + :backlinks: none |
| 8 | + :depth: 1 |
| 9 | + |
| 10 | +Overview |
| 11 | +^^^^^^^^ |
| 12 | + |
| 13 | +For testing or developing purposes, Presto can be configured to use a local |
| 14 | +filesystem directory as a Hive Metastore. |
| 15 | + |
| 16 | +The file-based metastore works only with the following connectors: |
| 17 | + |
| 18 | +* :doc:`/connector/deltalake` |
| 19 | +* :doc:`/connector/hive` |
| 20 | +* :doc:`/connector/hudi` |
| 21 | +* :doc:`/connector/iceberg` |
| 22 | + |
| 23 | +Configuring a File-Based Metastore |
| 24 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 25 | + |
| 26 | +1. In ``etc/catalog/``, find the catalog properties file for the supported |
| 27 | + connector. |
| 28 | + |
| 29 | +2. In the catalog properties file, set the following properties: |
| 30 | + |
| 31 | +.. code-block:: none |
| 32 | +
|
| 33 | + hive.metastore=file |
| 34 | + hive.metastore.catalog.dir=file:///<catalog-dir> |
| 35 | +
|
| 36 | +Replace ``<catalog-dir>`` in the example with the path to a directory on an |
| 37 | +accessible filesystem. |
| 38 | + |
| 39 | +Using a File-Based Warehouse |
| 40 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 41 | + |
| 42 | +For this example, assume the Hive connector is being used, and the properties |
| 43 | +in the Hive connector catalog file are set to the following: |
| 44 | + |
| 45 | +.. code-block:: none |
| 46 | +
|
| 47 | + connector.name=hive |
| 48 | + hive.metastore=file |
| 49 | + hive.metastore.catalog.dir=file:///data/hive_data/ |
| 50 | +
|
| 51 | +Create a schema |
| 52 | + |
| 53 | +.. code-block:: none |
| 54 | +
|
| 55 | + CREATE SCHEMA hive.warehouse; |
| 56 | +
|
| 57 | +This query creates a directory ``warehouse`` in the directory set for |
| 58 | +``hive.metastore.catalog.dir``, so the path to the new directory is |
| 59 | +``/data/hive_data/warehouse``. |
| 60 | + |
| 61 | +Create a table with any connector-supported file formats. For example, if the |
| 62 | +Hive connector is being configured: |
| 63 | + |
| 64 | +.. code-block:: none |
| 65 | +
|
| 66 | + CREATE TABLE hive.warehouse.orders_csv("order_name" varchar, "quantity" varchar) WITH (format = 'CSV'); |
| 67 | + CREATE TABLE hive.warehouse.orders_parquet("order_name" varchar, "quantity" int) WITH (format = 'PARQUET'); |
| 68 | +
|
| 69 | +These queries create folders as ``/data/hive_data/warehouse/orders_csv`` and |
| 70 | +``/data/hive_data/warehouse/orders_parquet``. Users can insert and query |
| 71 | +from these tables. |
0 commit comments