In the Part 1 and Part 2 of the tutorial series, we have learned how you can sample and connect to multiple endpoints and query the data using SQL, without you having to write a line of code. If you are new, we would recommend you to start from Part 1 of the tutorial series.
When you use Autonomous REST connector, it strives to a create correct schema information such as table name, column names, data types and assign a primary key, which you shouldn’t have any problem using it. But, as you start querying the API using SQL, there can be times where you might want to rename a table or field name to a value that avoids confusion for end users or change the data type for a certain field to a type that you think is appropriate or change the primary key to a different field in the generated table. In this tutorial, we will be walk you through on how to do this in a way that makes sense to you or your end user.
SELECT
*
FROM
_CONFIGURATION
{
"categories"
:{
"#path"
:[
"https://api.yelp.com/v3/categories /categories"
],
"alias"
:
"VarChar(48)"
,
"title"
:
"VarChar(52),#key"
,
"parent_aliases[]"
:
"VarChar(34)"
,
"country_whitelist[]"
:
"VarChar(3)"
,
"country_blacklist[]"
:
"VarChar(3)"
},
"events"
:{
"#path"
:[
],
"events[]"
:{
"attending_count"
:
"Integer"
,
"category"
:
"VarChar(64)"
,
"cost"
:
"VarChar(64)"
,
"cost_max"
:
"VarChar(64)"
,
"description"
:
"VarChar(238)"
,
"event_site_url"
:
"VarChar(310)"
,
"id"
:
"VarChar(75)"
,
"image_url"
:
"VarChar(102)"
,
"interested_count"
:
"Integer"
,
"is_canceled"
:
"Boolean"
,
"is_free"
:
"Boolean"
,
"is_official"
:
"Boolean"
,
"latitude"
:
"Double"
,
"longitude"
:
"Double"
,
"name"
:
"VarChar(64)"
,
"tickets_url"
:
"VarChar(64)"
,
"time_end"
:
"Timestamp(0)"
,
"time_start"
:
"Timestamp(0)"
,
"location"
:{
"address1"
:
"VarChar(64)"
,
"address2"
:
"VarChar(64)"
,
"address3"
:
"VarChar(64)"
,
"city"
:
"VarChar(64)"
,
"zip_code"
:
"Integer"
,
"country"
:
"VarChar(64)"
,
"state"
:
"VarChar(64)"
,
"display_address[]"
:
"VarChar(64)"
,
"cross_streets"
:
"VarChar(64)"
},
"business_id"
:
"VarChar(64)"
},
"total"
:
"Integer,#key"
},
"business"
:{
"#path"
:[
],
"businesses[]"
:{
"id"
:
"VarChar(64)"
,
"alias"
:
"VarChar(64)"
,
"name"
:
"VarChar(64)"
,
"image_url"
:
"VarChar(102)"
,
"is_closed"
:
"Boolean"
,
"url"
:
"VarChar(295)"
,
"review_count"
:
"Integer"
,
"categories[]"
:{
"alias"
:
"VarChar(21)"
,
"title"
:
"VarChar(33)"
},
"rating"
:
"Double"
,
"coordinates"
:{
"latitude"
:
"Double"
,
"longitude"
:
"Double"
},
"transactions[]"
:
"VarChar(64)"
,
"price"
:
"VarChar(64)"
,
"location"
:{
"address1"
:
"VarChar(64)"
,
"address2"
:
"VarChar(64)"
,
"address3"
:
"VarChar(64)"
,
"city"
:
"VarChar(64)"
,
"zip_code"
:
"Integer"
,
"country"
:
"VarChar(64)"
,
"state"
:
"VarChar(64)"
,
"display_address[]"
:
"VarChar(40)"
},
"phone"
:
"VarChar(64)"
,
"display_phone"
:
"VarChar(64)"
,
"distance"
:
"Double"
},
"total"
:
"Integer,#key"
,
"region"
:{
"center"
:{
"longitude"
:
"Double"
,
"latitude"
:
"Double"
}
},
"location"
:{
"#type"
:
"VarChar(64),#key"
,
"#virtual"
:
true
,
"#default"
:
"27617"
,
"#eq"
:
"location"
}
}
}
jdbc:datadirect:autorest:config=C:\<
path-to-file
>\YelpAuto.rest;
"location"
:{
"#type"
:
"VarChar(64),#key"
,
"#virtual"
:
true
,
"#default"
:
"27617"
,
"#eq"
:
"location"
}
"categories":{
"#path":[
"https://api.yelp.com/v3/categories /categories"
],
"alias":"VarChar(48),#key",
"title":"VarChar(52)",
"parent_aliases[]":"VarChar(34)",
"country_whitelist[]":"VarChar(3)",
"country_blacklist[]":"VarChar(3)"
}
"old_column_name<
new_column_name
>":"VarChar(52) "
"categories"
:{
"#path"
:[
"https://api.yelp.com/v3/categories /categories"
],
"alias<categorycode>"
:
"VarChar(48),#key"
,
"title"
:
"VarChar(52)"
,
"parent_aliases[]"
:
"VarChar(34)"
,
"country_whitelist[]"
:
"VarChar(3)"
,
"country_blacklist[]"
:
"VarChar(3)"
}
"categories"
:{
"#path"
:[
"https://api.yelp.com/v3/categories /categories"
],
"alias<categorycode>"
:
"LongVarChar(32000),#key"
,
"title"
:
"VarChar(52)"
,
"parent_aliases[]"
:
"VarChar(34)"
,
"country_whitelist[]"
:
"VarChar(3)"
,
"country_blacklist[]"
:
"VarChar(3)"
}
Syntax:
"old_table_name<
new_table_name
>[]":{}
Example
"business"
:{
"#path"
:[
],
"businesses[]"
:{
"id"
:
"VarChar(64)"
,
"alias"
:
"VarChar(64)"
,
"name"
:
"VarChar(64)"
,
"image_url"
:
"VarChar(102)"
,
"is_closed"
:
"Boolean"
,
"url"
:
"VarChar(295)"
,
"review_count"
:
"Integer"
,
"categories<business_category>[]"
:{
"alias"
:
"VarChar(21)"
,
"title"
:
"VarChar(33)"
},
"rating"
:
"Double"
,
"coordinates"
:{
"latitude"
:
"Double"
,
"longitude"
:
"Double"
},
"transactions[]"
:
"VarChar(64)"
,
"price"
:
"VarChar(64)"
,
"location"
:{
"address1"
:
"VarChar(64)"
,
"address2"
:
"VarChar(64)"
,
"address3"
:
"VarChar(64)"
,
"city"
:
"VarChar(64)"
,
"zip_code"
:
"Integer"
,
"country"
:
"VarChar(64)"
,
"state"
:
"VarChar(64)"
,
"display_address[]"
:
"VarChar(40)"
},
"phone"
:
"VarChar(64)"
,
"display_phone"
:
"VarChar(64)"
,
"distance"
:
"Double"
},
"total"
:
"Integer,#key"
,
"region"
:{
"center"
:{
"longitude"
:
"Double"
,
"latitude"
:
"Double"
}
},
"location"
:{
"#type"
:
"VarChar(64),#key"
,
"#virtual"
:
true
,
"#default"
:
"27617"
,
"#eq"
:
"location"
}
}
Feel free to play with the REST config file as per your needs and if you have any issues or questions, please contact us. We will be happy to help you. In the next tutorial (Part 4), we will look at how you can configure Autonomous REST Connector to page through all the results from endpoint beyond the first page.