0
0

こちらの続きです。

チュートリアルをウォークスルーします。

UCサーバーを起動しておきます。

bin/start-uc-server

カタログとスキーマの一覧

カタログの一覧

bin/uc catalog list
┌────────────┬───────────────────────────────────┬───────────────────────────────────┬───────────────────────────────────┬───────────────────────────────────┬───────────────────────────────────┐
│    NAME    │              COMMENT              │            PROPERTIES             │            CREATED_AT             │            UPDATED_AT             │                ID                 │
├────────────┼───────────────────────────────────┼───────────────────────────────────┼───────────────────────────────────┼───────────────────────────────────┼───────────────────────────────────┤
│unity       │Main catalog                       │{}                                 │1717996383345                      │null                               │17562adb-e6f8-463e-b82a-22264b06...│
└────────────┴───────────────────────────────────┴───────────────────────────────────┴───────────────────────────────────┴───────────────────────────────────┴───────────────────────────────────┘

スキーマの一覧

bin/uc schema list --catalog unity
┌────────────┬─────────────────────────┬─────────────────────────┬─────────────────────────┬─────────────────────────┬─────────────────────────┬─────────────────────────┬─────────────────────────┐
│    NAME    │      CATALOG_NAME       │         COMMENT         │       PROPERTIES        │        FULL_NAME        │       CREATED_AT        │       UPDATED_AT        │        SCHEMA_ID        │
├────────────┼─────────────────────────┼─────────────────────────┼─────────────────────────┼─────────────────────────┼─────────────────────────┼─────────────────────────┼─────────────────────────┤
│default     │unity                    │Default schema           │{}                       │unity.default            │1717996383390            │null                     │44abfe3b-d197-4202-9ae...│
└────────────┴─────────────────────────┴─────────────────────────┴─────────────────────────┴─────────────────────────┴─────────────────────────┴─────────────────────────┴─────────────────────────┘

Deltaテーブルの操作

テーブルの一覧

bin/uc table list --catalog unity --schema default
┌────────────┬────────────────┬────────────────┬────────────────┬────────────────┬────────────────┬────────────────┬────────────────┬────────────────┬────────────────┬────────────────┬────────────────┐
│    NAME    │  CATALOG_NAME  │  SCHEMA_NAME   │   TABLE_TYPE   │DATA_SOURCE_FORM│    COLUMNS     │STORAGE_LOCATION│    COMMENT     │   PROPERTIES   │   CREATED_AT   │   UPDATED_AT   │    TABLE_ID    │
│            │                │                │                │       AT       │                │                │                │                │                │                │                │
├────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┤
│numbers     │unity           │default         │EXTERNAL        │DELTA           │[{"name":"as_...│file:///Users...│External table  │{"key1":"valu...│1717996383547   │1717996383547   │3fcf3ca8-e0e4...│
├────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┤
│marksheet...│unity           │default         │EXTERNAL        │DELTA           │[{"name":"id"...│file:///tmp/m...│Uniform table   │{"key1":"valu...│1717996383545   │1717996383545   │8619f354-9d3a...│
├────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┤
│marksheet   │unity           │default         │MANAGED         │DELTA           │[{"name":"id"...│file:///Users...│Managed table   │{"key1":"valu...│1717996383535   │1717996383535   │4360b7b4-b606...│
└────────────┴────────────────┴────────────────┴────────────────┴────────────────┴────────────────┴────────────────┴────────────────┴────────────────┴────────────────┴────────────────┴────────────────┘

オプション--output jsonPrettyをつけると、すべての情報を表示することができます。

bin/uc table list --catalog unity --schema default --output jsonPretty
[ {
  "name" : "numbers",
  "catalog_name" : "unity",
  "schema_name" : "default",
  "table_type" : "EXTERNAL",
  "data_source_format" : "DELTA",
  "columns" : [ {
    "name" : "as_int",
    "type_text" : "int",
    "type_json" : "{\"name\":\"as_int\",\"type\":\"integer\",\"nullable\":false,\"metadata\":{}}",
    "type_name" : "INT",
    "type_precision" : 0,
    "type_scale" : 0,
    "type_interval_type" : null,
    "position" : 0,
    "comment" : "Int column",
    "nullable" : false,
    "partition_index" : null
  }, {
    "name" : "as_double",
    "type_text" : "double",
    "type_json" : "{\"name\":\"as_double\",\"type\":\"double\",\"nullable\":false,\"metadata\":{}}",
    "type_name" : "DOUBLE",
    "type_precision" : 0,
    "type_scale" : 0,
    "type_interval_type" : null,
    "position" : 1,
    "comment" : "Double column",
    "nullable" : false,
    "partition_index" : null
  } ],
  "storage_location" : "file:///Users/yayoi/UC/unitycatalog/etc/data/external/unity/default/tables/numbers/",
  "comment" : "External table",
  "properties" : {
    "key1" : "value1",
    "key2" : "value2"
  },
  "created_at" : 1717996383547,
  "updated_at" : 1717996383547,
  "table_id" : "3fcf3ca8-e0e4-4587-b28b-9cc50fc30d98"
}, {
  "name" : "marksheet_uniform",
  "catalog_name" : "unity",
  "schema_name" : "default",
  "table_type" : "EXTERNAL",
  "data_source_format" : "DELTA",
  "columns" : [ {
    "name" : "id",
    "type_text" : "int",
    "type_json" : "{\"name\":\"id\",\"type\":\"integer\",\"nullable\":false,\"metadata\":{}}",
    "type_name" : "INT",
    "type_precision" : 0,
    "type_scale" : 0,
    "type_interval_type" : null,
    "position" : 0,
    "comment" : "ID primary key",
    "nullable" : false,
    "partition_index" : null
  }, {
    "name" : "name",
    "type_text" : "string",
    "type_json" : "{\"name\":\"name\",\"type\":\"string\",\"nullable\":false,\"metadata\":{}}",
    "type_name" : "STRING",
    "type_precision" : 0,
    "type_scale" : 0,
    "type_interval_type" : null,
    "position" : 1,
    "comment" : "Name of the entity",
    "nullable" : false,
    "partition_index" : null
  }, {
    "name" : "marks",
    "type_text" : "int",
    "type_json" : "{\"name\":\"marks\",\"type\":\"integer\",\"nullable\":true,\"metadata\":{}}",
    "type_name" : "INT",
    "type_precision" : 0,
    "type_scale" : 0,
    "type_interval_type" : null,
    "position" : 2,
    "comment" : "Marks of the entity",
    "nullable" : true,
    "partition_index" : null
  } ],
  "storage_location" : "file:///tmp/marksheet_uniform",
  "comment" : "Uniform table",
  "properties" : {
    "key1" : "value1",
    "key2" : "value2"
  },
  "created_at" : 1717996383545,
  "updated_at" : 1717996383545,
  "table_id" : "8619f354-9d3a-4d2e-bef1-fb6829ac80d9"
}, {
  "name" : "marksheet",
  "catalog_name" : "unity",
  "schema_name" : "default",
  "table_type" : "MANAGED",
  "data_source_format" : "DELTA",
  "columns" : [ {
    "name" : "id",
    "type_text" : "int",
    "type_json" : "{\"name\":\"id\",\"type\":\"integer\",\"nullable\":false,\"metadata\":{}}",
    "type_name" : "INT",
    "type_precision" : 0,
    "type_scale" : 0,
    "type_interval_type" : null,
    "position" : 0,
    "comment" : "ID primary key",
    "nullable" : false,
    "partition_index" : null
  }, {
    "name" : "name",
    "type_text" : "string",
    "type_json" : "{\"name\":\"name\",\"type\":\"string\",\"nullable\":false,\"metadata\":{}}",
    "type_name" : "STRING",
    "type_precision" : 0,
    "type_scale" : 0,
    "type_interval_type" : null,
    "position" : 1,
    "comment" : "Name of the entity",
    "nullable" : false,
    "partition_index" : null
  }, {
    "name" : "marks",
    "type_text" : "int",
    "type_json" : "{\"name\":\"marks\",\"type\":\"integer\",\"nullable\":true,\"metadata\":{}}",
    "type_name" : "INT",
    "type_precision" : 0,
    "type_scale" : 0,
    "type_interval_type" : null,
    "position" : 2,
    "comment" : "Marks of the entity",
    "nullable" : true,
    "partition_index" : null
  } ],
  "storage_location" : "file:///Users/yayoi/UC/unitycatalog/etc/data/managed/unity/default/tables/marksheet/",
  "comment" : "Managed table",
  "properties" : {
    "key1" : "value1",
    "key2" : "value2"
  },
  "created_at" : 1717996383535,
  "updated_at" : 1717996383535,
  "table_id" : "4360b7b4-b606-4b0e-a0e9-bb1484d4101e"
} ]

メタデータの表示

bin/uc table get --full_name unity.default.numbers
┌────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────┐
│        KEY         │                                               VALUE                                                │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│NAME                │numbers                                                                                             │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│CATALOG_NAME        │unity                                                                                               │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│SCHEMA_NAME         │default                                                                                             │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│TABLE_TYPE          │EXTERNAL                                                                                            │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│DATA_SOURCE_FORMAT  │DELTA                                                                                               │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│COLUMNS             │{"name":"as_int","type_text":"int","type_json":"{\"name\":\"as_int\",\"type\":\"integer\",\"nullable│
│                    │\":false,\"metadata\":{}}","type_name":"INT","type_precision":0,"type_scale":0,"type_interval_type":│
│                    │null,"position":0,"comment":"Int                    column","nullable":false,"partition_index":null}│
│                    │{"name":"as_double","type_text":"double","type_json":"{\"name\":\"as_double\",\"type\":\"double\",\"│
│                    │nullable\":false,\"metadata\":{}}","type_name":"DOUBLE","type_precision":0,"type_scale":0,"type_inte│
│                    │rval_type":null,"position":1,"comment":"Double column","nullable":false,"partition_index":null}     │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│STORAGE_LOCATION    │file:///Users/yayoi/UC/unitycatalog/etc/data/external/unity/default/tables/numbers/                 │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│COMMENT             │External table                                                                                      │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│PROPERTIES          │{"key1":"value1","key2":"value2"}                                                                   │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│CREATED_AT          │1717996383547                                                                                       │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│UPDATED_AT          │1717996383547                                                                                       │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│TABLE_ID            │3fcf3ca8-e0e4-4587-b28b-9cc50fc30d98                                                                │
└────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────┘

テーブルの読み込み

bin/uc table read --full_name unity.default.numbers
┌───────────────────────────────────────┬──────────────────────────────────────┐
│as_int(integer)                        │as_double(double)                     │
├───────────────────────────────────────┼──────────────────────────────────────┤
│564                                    │188.75535598441473                    │
├───────────────────────────────────────┼──────────────────────────────────────┤
│755                                    │883.6105633023361                     │
├───────────────────────────────────────┼──────────────────────────────────────┤
│644                                    │203.4395591086936                     │
├───────────────────────────────────────┼──────────────────────────────────────┤
│75                                     │277.8802190765611                     │
├───────────────────────────────────────┼──────────────────────────────────────┤
│42                                     │403.857969425109                      │
├───────────────────────────────────────┼──────────────────────────────────────┤
│680                                    │797.6912200731077                     │
├───────────────────────────────────────┼──────────────────────────────────────┤
│821                                    │767.7998537403159                     │
├───────────────────────────────────────┼──────────────────────────────────────┤
│484                                    │344.00373976089304                    │
├───────────────────────────────────────┼──────────────────────────────────────┤
│477                                    │380.6785614543262                     │
├───────────────────────────────────────┼──────────────────────────────────────┤
│131                                    │35.44373222835895                     │
├───────────────────────────────────────┼──────────────────────────────────────┤
│294                                    │209.32243623208947                    │
├───────────────────────────────────────┼──────────────────────────────────────┤
│150                                    │329.19730274053694                    │
├───────────────────────────────────────┼──────────────────────────────────────┤
│539                                    │425.66102859000944                    │
├───────────────────────────────────────┼──────────────────────────────────────┤
│247                                    │477.742227230588                      │
├───────────────────────────────────────┼──────────────────────────────────────┤
│958                                    │509.3712727285101                     │
└───────────────────────────────────────┴──────────────────────────────────────┘

テーブルの作成

bin/uc table create --full_name unity.default.myTable --columns "col1 int, col2 double" --storage_location /tmp/uc/myTable
Table created successfully at: file:///tmp/uc/myTable
┌────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────┐
│        KEY         │                                               VALUE                                                │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│NAME                │myTable                                                                                             │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│CATALOG_NAME        │unity                                                                                               │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│SCHEMA_NAME         │default                                                                                             │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│TABLE_TYPE          │EXTERNAL                                                                                            │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│DATA_SOURCE_FORMAT  │DELTA                                                                                               │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│COLUMNS             │{"name":"col1","type_text":"int","type_json":"{\"name\":\"col1\",\"type\":\"integer\",\"nullable\":t│
│                    │rue,\"metadata\":{}}","type_name":"INT","type_precision":0,"type_scale":0,"type_interval_type":null,│
│                    │"position":0,"comment":null,"nullable":true,"partition_index":null}                                 │
│                    │{"name":"col2","type_text":"double","type_json":"{\"name\":\"col2\",\"type\":\"double\",\"nullable\"│
│                    │:true,\"metadata\":{}}","type_name":"DOUBLE","type_precision":0,"type_scale":0,"type_interval_type":│
│                    │null,"position":1,"comment":null,"nullable":true,"partition_index":null}                            │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│STORAGE_LOCATION    │/tmp/uc/myTable                                                                                     │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│COMMENT             │null                                                                                                │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│PROPERTIES          │{}                                                                                                  │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│CREATED_AT          │1718410591952                                                                                       │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│UPDATED_AT          │1718410591952                                                                                       │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│TABLE_ID            │2740a62f-210f-487a-930a-e57c26a6ac20                                                                │
└────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────┘

テーブルへの書き込み

以下のコマンドではランダムに生成したデータをテーブルに書き込みます。

bin/uc table write --full_name unity.default.myTable
Table written to successfully at: file:///tmp/uc/myTable/
┌────────────────────┬──────────────────────────────────────────────────┐
│        KEY         │                      VALUE                       │
└────────────────────┴──────────────────────────────────────────────────┘
bin/uc table read --full_name unity.default.myTable
┌───────────────────────────────────────┬──────────────────────────────────────┐
│col1(integer)                          │col2(double)                          │
├───────────────────────────────────────┼──────────────────────────────────────┤
│394                                    │357.2492910249696                     │
├───────────────────────────────────────┼──────────────────────────────────────┤
│561                                    │486.48668042307474                    │
├───────────────────────────────────────┼──────────────────────────────────────┤
│758                                    │416.99888126653195                    │
├───────────────────────────────────────┼──────────────────────────────────────┤
│98                                     │706.9843531187902                     │
├───────────────────────────────────────┼──────────────────────────────────────┤
│52                                     │220.3889224464608                     │
├───────────────────────────────────────┼──────────────────────────────────────┤
│344                                    │420.09398615975044                    │
├───────────────────────────────────────┼──────────────────────────────────────┤
│584                                    │382.7593558141724                     │
├───────────────────────────────────────┼──────────────────────────────────────┤
│458                                    │211.4124318985574                     │
├───────────────────────────────────────┼──────────────────────────────────────┤
│725                                    │202.79002551174307                    │
├───────────────────────────────────────┼──────────────────────────────────────┤
│318                                    │61.412447874107265                    │
├───────────────────────────────────────┼──────────────────────────────────────┤
│909                                    │898.3751162656671                     │
├───────────────────────────────────────┼──────────────────────────────────────┤
│525                                    │124.63508094555908                    │
├───────────────────────────────────────┼──────────────────────────────────────┤
│425                                    │600.8869658910287                     │
├───────────────────────────────────────┼──────────────────────────────────────┤
│76                                     │214.12822798784137                    │
├───────────────────────────────────────┼──────────────────────────────────────┤
│814                                    │421.1564193905256                     │
└───────────────────────────────────────┴──────────────────────────────────────┘

DuckDBによるDeltaテーブルのオペレーション

割愛します。

ボリュームのオペレーション

ボリュームとはUnity Catalogで管理されるファイルシステムのマウントポイントのようなものです。任意のファイルを格納することができます。

ボリュームの一覧

bin/uc volume list --catalog unity --schema default
┌────────────┬───────────────────┬───────────────────┬───────────────────┬───────────────────┬───────────────────┬───────────────────┬───────────────────┬───────────────────┬───────────────────┐
│CATALOG_NAME│    SCHEMA_NAME    │       NAME        │      COMMENT      │    CREATED_AT     │    UPDATED_AT     │     VOLUME_ID     │    VOLUME_TYPE    │ STORAGE_LOCATION  │     FULL_NAME     │
├────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┤
│unity       │default            │txt_files          │null               │1717996383550      │1717996383550      │a38cd676-e90f-41...│MANAGED            │file:///Users/ya...│unity.default.tx...│
├────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┤
│unity       │default            │json_files         │null               │1717996383550      │1717996383550      │7429a7f2-3ad9-4d...│EXTERNAL           │file:///Users/ya...│unity.default.js...│
└────────────┴───────────────────┴───────────────────┴───────────────────┴───────────────────┴───────────────────┴───────────────────┴───────────────────┴───────────────────┴───────────────────┘

メタデータの取得

bin/uc volume get --full_name unity.default.json_files
┌────────────────────┬───────────────────────────────────────────────────────────────────────────────────────┐
│        KEY         │                                         VALUE                                         │
├────────────────────┼───────────────────────────────────────────────────────────────────────────────────────┤
│CATALOG_NAME        │unity                                                                                  │
├────────────────────┼───────────────────────────────────────────────────────────────────────────────────────┤
│SCHEMA_NAME         │default                                                                                │
├────────────────────┼───────────────────────────────────────────────────────────────────────────────────────┤
│NAME                │json_files                                                                             │
├────────────────────┼───────────────────────────────────────────────────────────────────────────────────────┤
│COMMENT             │null                                                                                   │
├────────────────────┼───────────────────────────────────────────────────────────────────────────────────────┤
│CREATED_AT          │1717996383550                                                                          │
├────────────────────┼───────────────────────────────────────────────────────────────────────────────────────┤
│UPDATED_AT          │1717996383550                                                                          │
├────────────────────┼───────────────────────────────────────────────────────────────────────────────────────┤
│VOLUME_ID           │7429a7f2-3ad9-4df5-b567-c9cca5ffc8df                                                   │
├────────────────────┼───────────────────────────────────────────────────────────────────────────────────────┤
│VOLUME_TYPE         │EXTERNAL                                                                               │
├────────────────────┼───────────────────────────────────────────────────────────────────────────────────────┤
│STORAGE_LOCATION    │file:///Users/yayoi/UC/unitycatalog/etc/data/external/unity/default/volumes/json_files/│
├────────────────────┼───────────────────────────────────────────────────────────────────────────────────────┤
│FULL_NAME           │unity.default.json_files                                                               │
└────────────────────┴───────────────────────────────────────────────────────────────────────────────────────┘

ディレクトリやファイルの一覧

bin/uc volume read --full_name unity.default.json_files
d.json [file]
c.json [file]
dir1 [directory]

ファイルの読み込み

bin/uc volume read --full_name unity.default.json_files --path c.json
{
  "marks" :[
    {"name" :  "a" , "score" :  20},
    {"name" :  "b" , "score" :  30},
    {"name" :  "c" , "score" :  40},
    {"name" :  "d" , "score" :  50}
  ]
}

サブディレクトリの内容の一覧

bin/uc volume read --full_name unity.default.json_files --path dir1
e.json [file]

ボリュームの作成

bin/uc volume create --full_name unity.default.myVolume --storage_location /tmp/myVolume
┌────────────────────┬──────────────────────────────────────────────────┐
│        KEY         │                      VALUE                       │
├────────────────────┼──────────────────────────────────────────────────┤
│CATALOG_NAME        │unity                                             │
├────────────────────┼──────────────────────────────────────────────────┤
│SCHEMA_NAME         │default                                           │
├────────────────────┼──────────────────────────────────────────────────┤
│NAME                │myVolume                                          │
├────────────────────┼──────────────────────────────────────────────────┤
│COMMENT             │null                                              │
├────────────────────┼──────────────────────────────────────────────────┤
│CREATED_AT          │1718410739078                                     │
├────────────────────┼──────────────────────────────────────────────────┤
│UPDATED_AT          │1718410739078                                     │
├────────────────────┼──────────────────────────────────────────────────┤
│VOLUME_ID           │b5124f06-c96b-4b9a-b657-82c2e3cbabb6              │
├────────────────────┼──────────────────────────────────────────────────┤
│VOLUME_TYPE         │EXTERNAL                                          │
├────────────────────┼──────────────────────────────────────────────────┤
│STORAGE_LOCATION    │file:///tmp/myVolume                              │
├────────────────────┼──────────────────────────────────────────────────┤
│FULL_NAME           │unity.default.myVolume                            │
└────────────────────┴──────────────────────────────────────────────────┘

関数のオペレーション

関数の一覧

bin/uc function list --catalog unity --schema default
┌────────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┐
│    NAME    │CATALOG_│SCHEMA_N│INPUT_PA│DATA_TYP│FULL_DAT│RETURN_P│ROUTINE_│ROUTINE_│ROUTINE_│PARAMETE│IS_DETER│SQL_DATA│IS_NULL_│SECURITY│SPECIFIC│COMMENT │PROPERTI│FULL_NAM│CREATED_│UPDATED_│FUNCTION│EXTERNAL│
│            │  NAME  │  AME   │  RAMS  │   E    │ A_TYPE │ ARAMS  │  BODY  │DEFINITI│DEPENDEN│R_STYLE │MINISTIC│_ACCESS │  CALL  │ _TYPE  │ _NAME  │        │   ES   │   E    │   AT   │   AT   │  _ID   │_LANGUAG│
│            │        │        │        │        │        │        │        │   ON   │  CIES  │        │        │        │        │        │        │        │        │        │        │        │        │   E    │
├────────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤
│sum         │unity   │default │{"par...│INT     │INT     │null    │EXTERNAL│t = x...│null    │S       │true    │NO_SQL  │false   │DEFINER │sum     │Adds ...│null    │unity...│17180...│null    │df40c...│python  │
├────────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤
│lowercase   │unity   │default │{"par...│STRING  │STRING  │null    │EXTERNAL│g = s...│null    │S       │true    │NO_SQL  │false   │DEFINER │lower...│Conve...│null    │unity...│17180...│null    │74d2c...│python  │
└────────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┘

メタデータの取得

bin/uc function get --full_name unity.default.sum
┌────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────┐
│        KEY         │                                               VALUE                                                │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│NAME                │sum                                                                                                 │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│CATALOG_NAME        │unity                                                                                               │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│SCHEMA_NAME         │default                                                                                             │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│INPUT_PARAMS        │{"parameters":[{"name":"x","type_text":"int","type_json":"{\"name\":\"x\",\"type\":\"integer\",\"nul│
│                    │lable\":false,\"metadata\":{}}","type_name":"INT","type_precision":null,"type_scale":null,"type_inte│
│                    │rval_type":null,"position":0,"parameter_mode":"IN","parameter_type":"PARAM","parameter_default":null│
│                    │,"comment":null},{"name":"y","type_text":"int","type_json":"{\"name\":\"y\",\"type\":\"integer\",\"n│
│                    │ullable\":false,\"metadata\":{}}","type_name":"INT","type_precision":null,"type_scale":null,"type_in│
│                    │terval_type":null,"position":1,"parameter_mode":"IN","parameter_type":"PARAM","parameter_default":nu│
│                    │ll,"comment":null},{"name":"z","type_text":"int","type_json":"{\"name\":\"z\",\"type\":\"integer\",\│
│                    │"nullable\":false,\"metadata\":{}}","type_name":"INT","type_precision":null,"type_scale":null,"type_│
│                    │interval_type":null,"position":2,"parameter_mode":"IN","parameter_type":"PARAM","parameter_default":│
│                    │null,"comment":null}]}                                                                              │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│DATA_TYPE           │INT                                                                                                 │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│FULL_DATA_TYPE      │INT                                                                                                 │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│RETURN_PARAMS       │null                                                                                                │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ROUTINE_BODY        │EXTERNAL                                                                                            │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ROUTINE_DEFINITION  │t = x + y + z\nreturn t                                                                             │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ROUTINE_DEPENDENCIES│null                                                                                                │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│PARAMETER_STYLE     │S                                                                                                   │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│IS_DETERMINISTIC    │true                                                                                                │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│SQL_DATA_ACCESS     │NO_SQL                                                                                              │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│IS_NULL_CALL        │false                                                                                               │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│SECURITY_TYPE       │DEFINER                                                                                             │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│SPECIFIC_NAME       │sum                                                                                                 │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│COMMENT             │Adds two numbers.                                                                                   │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│PROPERTIES          │null                                                                                                │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│FULL_NAME           │unity.default.sum                                                                                   │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│CREATED_AT          │1718053983553                                                                                       │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│UPDATED_AT          │null                                                                                                │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│FUNCTION_ID         │df40ce66-e4ce-4a4f-acce-90466a4302e6                                                                │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│EXTERNAL_LANGUAGE   │python                                                                                              │
└────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────┘

関数の呼び出し

bin/uc function call --full_name unity.default.sum --input_params "1,2,3"
6

関数の作成

bin/uc function create --full_name unity.default.myFunction --data_type INT --input_params "a int, b int" --def "c=a*b\nreturn c"
┌────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────┐
│        KEY         │                                               VALUE                                                │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│NAME                │myFunction                                                                                          │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│CATALOG_NAME        │unity                                                                                               │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│SCHEMA_NAME         │default                                                                                             │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│INPUT_PARAMS        │{"parameters":[{"name":"a","type_text":"int","type_json":"{\"name\":\"a\",\"type\":\"integer\",\"nul│
│                    │lable\":true,\"metadata\":{}}","type_name":"INT","type_precision":null,"type_scale":null,"type_inter│
│                    │val_type":null,"position":0,"parameter_mode":null,"parameter_type":null,"parameter_default":null,"co│
│                    │mment":null},{"name":"b","type_text":"int","type_json":"{\"name\":\"b\",\"type\":\"integer\",\"nulla│
│                    │ble\":true,\"metadata\":{}}","type_name":"INT","type_precision":null,"type_scale":null,"type_interva│
│                    │l_type":null,"position":1,"parameter_mode":null,"parameter_type":null,"parameter_default":null,"comm│
│                    │ent":null}]}                                                                                        │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│DATA_TYPE           │INT                                                                                                 │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│FULL_DATA_TYPE      │INT                                                                                                 │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│RETURN_PARAMS       │null                                                                                                │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ROUTINE_BODY        │EXTERNAL                                                                                            │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ROUTINE_DEFINITION  │c=a*b\nreturn c                                                                                     │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ROUTINE_DEPENDENCIES│null                                                                                                │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│PARAMETER_STYLE     │S                                                                                                   │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│IS_DETERMINISTIC    │true                                                                                                │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│SQL_DATA_ACCESS     │NO_SQL                                                                                              │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│IS_NULL_CALL        │true                                                                                                │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│SECURITY_TYPE       │DEFINER                                                                                             │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│SPECIFIC_NAME       │myFunction                                                                                          │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│COMMENT             │null                                                                                                │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│PROPERTIES          │null                                                                                                │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│FULL_NAME           │unity.default.myFunction                                                                            │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│CREATED_AT          │1718411072913                                                                                       │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│UPDATED_AT          │null                                                                                                │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│FUNCTION_ID         │79a07258-9e63-405b-a36a-7b2bdea812cc                                                                │
├────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│EXTERNAL_LANGUAGE   │python                                                                                              │
└────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────┘

呼び出してみます。

bin/uc function call --full_name unity.default.myFunction --input_params "2,3"

積が返ってきます。

6

Iceberg REST Catalog経由でのDelta UniFormテーブルの読み込み

割愛します。

はじめてのDatabricks

はじめてのDatabricks

Databricks無料トライアル

Databricks無料トライアル

0
0
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
0
0