Example: Comparing Data Types - Teradata Vantage NewSQL Engine - 16.20

Teradata Vantageā„¢ DATASET Data Type

prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1198-162K

This example compares CHAR/VARCHAR/CLOB/JSON data types that represent an Avro schema.

/*fail due to name of symbol mismatch*/
SELECT SchemaEqual(
'{ "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 SchemaEqual(
'{ "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 - everything is equal and doc is ignored*/
SELECT SchemaEqual(
'{ "type" : "array",
   "items" : {
	"type": "record",
	"name": "test",
	"doc": "this is unique01",
	"fields" : [
		{"name": "a", "type": "long"},
		{"name": "b", "type": "string"}
	]
 }}',
'{ "type" : "array",
   "items" : {
	"type": "record",
	"name": "test",
	"doc": "this is unique02",
	"fields" : [
		{"name": "a", "type": "long"},
		{"name": "b", "type": "string"}
	]
 }}');
> 1