ODBC Driver for Azure Cosmos DB

Build 23.0.8839

カスタムスキーマ定義

自動スキーマ検出 で作成されたテーブルスキーマを、スキーマファイルに保存することで拡張できます。スキーマファイルはシンプルな形式で、変更は簡単です。

スキーマファイルの生成

GenerateSchemaFiles を"OnStart" に設定すると、接続時にすべてのテーブルのスキーマを保持します。テーブルスキーマを必要に応じて生成することもできます。GenerateSchemaFiles を"OnUse" に設定して、テーブルにSELECT クエリを実行します。

例えば、レストランのデータセットのスキーマを考えてみましょう。これはAzure Cosmos DB が提供するサンプルデータです。

コレクションからのサンプルドキュメントは以下のとおりです。

{
  "address":{
    "building":"461",
      "coord":[
        -74.138492,
        40.631136
      ],
      "street":"Port Richmond Ave",
      "zipcode":"10302"
   },
   "borough":"Staten Island",
   "cuisine":"Other",
   "name":"Indian Oven",
   "restaurant_id":"50018994"
}

スキーマのカスタマイズ

GenerateSchemaFiles が設定されている場合、本製品 はLocation プロパティで指定されたフォルダ内にスキーマを格納します。 生成されたスキーマでカラムの動作を変更できます。

次のスキーマは、other:bsonpath プロパティを使用して、特定のカラムのデータをコレクションのどこに取得するかを定義します。このモデルを使って、階層構造のアービトラリーレベルをフラット化することができます。

以下はレストランのデータセットの対応するカラム定義です。カスタムスキーマ例 では、完全なスキーマを確認できます。

<rsb:script xmlns:rsb="http://www.rssbus.com/ns/rsbscript/2">  

  <rsb:info title="StaticRestaurants" description="Custom Schema for the restaurants data set.">  
    <!-- Column definitions -->
    <attr   name="_rid"               xs:type="string"   key="true"   other:collrid="hWdRAKRi3Pg=" other:dbrid="hWdRAA==" other:partitionpath="/name" />
	<attr   name="borough"            xs:type="string"   />
    <attr   name="cuisine"            xs:type="string"   />
    <attr   name="address.building"   xs:type="string"   />
    <attr   name="address.street"     xs:type="string"   />
    <attr   name="address.coord.0"    xs:type="double"   />
    <attr   name="address.coord.1"    xs:type="double"   />
    <input name="rows@next" desc="Internal attribute used for paging through data."  />
  </rsb:info>  

  <rsb:set attr="collection" value="restaurants"/>

</rsb:script>

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 23.0.8839