17.10 - 例: スキーマの一致 - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - DATASETデータ型

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
2021年7月
Content Type
プログラミング リファレンス
Publication ID
B035-1198-171K-JPN
Language
日本語 (日本)

以下のスキーマは、さまざまなスキーマ照合の例を示しています。スキーマが一致する場合もあれば、一致しない場合もあります。

/*fail due to name of symbol mismatch*/
SELECT SchemaMatch(
'{ "type": "enum",
   "name": "Suit",
   "symbols" : ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
 }'
, 
'{ "type": "enum",
   "name": "Suits",
   "symbols" : ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
 }');
> 0

/*fail due to structural mismatch*/
SELECT SchemaMatch(
'{ "type": "enum",
   "name": "Suit",
   "symbols" : ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
 }'
, 
'{ "type" : "array",
   "items" : {
	"type": "record",
	"name": "test",
	"doc": "this is unique01",
	"fields" : [
		{"name": "a", "type": "long"},
		{"name": "b", "type": "string"}
	]
 }}');
> 0

/*success - doc is ignored, ordering of names does not matter, long promotes to double, and int promotes to float*/
SELECT SchemaMatch(
'{ "type" : "array",
   "items" : {
	"type": "record",
	"name": "test",
	"doc": "this is unique01",
	"fields" : [
		{"name": "a", "type": "long"},
		{"name": "b", "type": "int"}
	]
 }}', 
'{ "type" : "array",
   "items" : {
	"type": "record",
	"name": "test",
	"doc": "this is unique02",
	"fields" : [
		{"name": "b", "type": "float"},
		{"name": "a", "type": "double"}
	]
 }}');
> 1