2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【ADB】Iceberg表を操作するコマンド

2
Posted at

ADB上からのIceberg表の操作に関するコマンドをメモしておきます。

検証環境では、Snowflake Open Catalog の REST Catalog に紐づけたカタログを経由して、S3にIceberg表を作成しました。

テーブルの作成

SET SERVEROUTPUT ON;

DECLARE
  l_table_definition CLOB;
  l_out_metadata     CLOB;
BEGIN
  l_table_definition := q'~{
    "name": "<table_name>",
    "location": "<object_storage_location_for_this_table>",
    "schema": {
      "type": "struct",
      "schema-id": 0,
      "identifier-field-ids": [],
      "fields": [
        {
          "id": 1,
          "name": "<column_name>",
          "required": false,
          "type": "<data_type>"
        },
        {
          "id": 2,
          "name": "<column_name>",
          "required": false,
          "type": "<data_type>"
        }
      ]
    },
    "partition-spec": {
      "spec-id": 0,
      "fields": []
    },
    "properties": {
      "format-version": "2",
      "write.format.default": "parquet"
    }
  }~';

  DBMS_CATALOG.CREATE_ICEBERG_TABLE(
    catalog_name      => '<catalog_name>',
    schema_name       => '<schema_name>',
    table_name        => '<table_name>',
    table_definition  => l_table_definition,
    out_metadata      => l_out_metadata
  );

  DBMS_OUTPUT.PUT_LINE(DBMS_LOB.SUBSTR(l_out_metadata, 4000, 1));
END;
/
  • locationの指定について
"location": "<object_storage_scheme>://<bucket_or_container>/<base_directory>/<schema_or_namespace>/<table_name>/"

例:

"location": "s3://s3-iceberg-bucket/adb-created-iceberg/PUBLIC/ICEBERG_ADB_CREATE_SMOKE_TEST_202605/"

テーブルの削除

BEGIN
  DBMS_CATALOG.DROP_TABLE(
    catalog_name => '<catalog_name>',
    schema_name  => '<schema_or_namespace>',
    table_name   => '<table_name>'
  );
END;
/

例:

BEGIN
  DBMS_CATALOG.DROP_TABLE(
    catalog_name => '<catalog_name>',
    schema_name  => '<schema_or_namespace PUBLICなど>',
    table_name   => 'ICEBERG_ADB_CREATE_SMOKE_TEST'
  );
END;
/

カタログのメタデータキャッシュをフラッシュ

BEGIN
  DBMS_CATALOG.FLUSH_CATALOG_CACHE(
    catalog_name => '<catalog_name>'
  );
END;
/
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?