Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Virtualization Tutorial: JSON_TABLE Queries

Similar presentations


Presentation on theme: "Data Virtualization Tutorial: JSON_TABLE Queries"— Presentation transcript:

1 Data Virtualization Tutorial: JSON_TABLE Queries
Hello, and welcome to the Tutorial Series for Cisco Information Server, or CIS. In this tutorial, we discuss the JSON_TABLE query capability in CIS.

2 For more details… Resources: Additional information: Archives
Documentation Training Resources: Archives Data files Tutorial Document Note that Tutorials are NOT meant to be comprehensive training modules. Instead, they demonstrate a very basic use case that can be built quickly and easily. However, the Data Virtualization Knowledge Base contains additional information that will help you learn more and go deeper. Additional resources in the Knowledge Base include: <CLICK> Resources used to build the tutorial, such as Data Virtualization Archive files, data source files, and a document version of this tutorial… <CLICK> … and additional information, including documentation and training materials.

3 Agenda What are they and why do they matter? How-to Summary
Here is our agenda. We begin by defining JSON_TABLE queries and outlining their importance in Data Virtualization projects. Next we demonstrate the basics of JSON_TABLE queries. Finally, we summarize the contents of this tutorial.

4 Agenda What are they and why do they matter? How-to Summary
Let’s begin by discussing what JSON_TABLE queries are, and why they are important for Data Virtualization.

5 What are they? JSON_TABLE Queries JSON: JavaScript Object Notation
Widely used to collect and transfer data, especially via the Web Hierarchical format, but less verbose than XML JSON_TABLE enables queries that return results in table format JSON stands for JavaScript Object notation. It is a structuring convention for data. JSON files are widely used to collect and transfer data, especially via the web. JSON organizes data in a hierarchical format that is analogous to XML, but less verbose. JSON_TABLE functionality in CIS enables queries that read data in JSON format and return results in tables that can then be joined with other data in CIS.

6 Why do they matter? JSON_TABLE Queries
Enables JOINS of JSON structures with relational data Many web service APIs return JSON JSON_TABLE functionality is important to our customers because it enables them to create virtual views and procedures that join JSON data with relational data from other data sources. JSON is an especially popular format for data returned by web services, and is becoming increasingly important for enterprise needs.

7 Agenda What is it and why does it matter? How-to Summary
Next, let’s walk through a very basic demo of JSON_TABLE queries in CIS.

8 Here is the business problem…
CIS Here is the business problem that we illustrate in this demo. Data Consumers use CIS to access federated virtual views of data. In this case, one of our data sources is a RESTful web services that returns a JSON data structure. We need to flatten this structure into a tabular form that can be joined with other enterprise data.

9 Before you begin… You can easily build the resources needed for this demo from scratch. However, users may import a CAR file that is available with the Additional Resources that accompany this demo. The actual web service we access in the demo is available on a public web site.

10 Demo: Reviewing JSON to XML
Prior to CIS 7.0.2, the most practical way to bring JSON data into CIS was to allow CIS to automatically transform it to XML. The resulting XML can then be flattened in a transformation, and joined with other data. This approach is still available in CIS. Let’s quickly review it before moving on to JSON_TABLE. <CLICK> The public URL shown here contains this very simple RESTful web service that returns a result in JSON format. We specify the URL and select JSON format. <CLICK> We define a getData operation… <CLICK> … and use Design By Example to identify the data elements. We select the top-level element, Store… <CLICK> … and use it as the Data Type for an output parameter, which we name Result.

11 Demo: Reviewing JSON to XML
Now we can execute the getData operation, and our result is automatically rendered as XML. We can then flatten this XML with the CIS transformation editor, and join it with other data.

12 Demo: JSON_Table Query with REST Data
Next, let’s use JSON_TABLE and eliminate the conversion to XML. We define a new REST data source that uses the same URL, and also selects the JSON format checkbox. Notice, though, that the getData operation on this new data source does not define any output parameter. <CLICK> Now when we run the getData operation, the JSON is returned unchanged. <CLICK> Note that CIS assigns the name “output” to the JSON parameter. This will be important when we define our JSON_TABLE statement in a moment.

13 Demo: JSON_Table Query with REST Data
Now we can create a view that uses the JSON_TABLE functionality to return a SQL result set. We must define the view in the SQL tab of the view editor. We want to return three columns: myTitle, author, and price.

14 Demo: JSON_Table Query with REST Data
Content Provider Row Provider Columns Clause The JSON_TABLE expression is defined in the FROM clause of the SQL Statement. It uses three ordered elements, enclosed in parentheses… <CLICK> … the content provider… <CLICK> … the row provider… <CLICK> … and a Columns clause. <CLICK> At the end of the FROM clause, we define the source of the data. To do so, we drag in the getData operation from the Studio namespace to get the fully-qualified name, and specify its alias as JSONFILE. Let’s look at the JSON_TABLE statement in more detail.

15 Demo: JSON_Table Query with REST Data
The first element is the JSON content provider. JSONFILE is the alias we used for the resource, and “output” is the name CIS defined for the result coming back from the web service call. The comma specifies an implicit CROSS JOIN with the second element. If you wish, you can make this relationship explicit by typing the words CROSS JOIN in place of the comma.

16 Demo: JSON_Table Query with REST Data
The second element is the Row Provider. This is a path to the row level of the JSON structure. Note the dollar sign at the beginning of the path. JSON paths were designed to be logically compatible with XPATH path expressions. However, since a JSON structure is not required to have a root member, JSON assigns the abstract name “dollar-sign” to the outermost level object.

17 Demo: JSON_Table Query with REST Data
The third element is the COLUMNS clause. For each column, we define an alias, a SQL data type, and a PATH to the column. In these PATH expressions, the dollar sign references the Row Provider element. We also defined an alias, JT, which is optional.

18 Demo: JSON_Table Query with REST Data
We execute the view, and a SQL result set is returned.

19 Demo: JSON_Table Query with Literal
As shown here, it is also possible to specify the Content Provider element as a literal. Here we use a literal in a view, but it can also be very valuable if we have a JSON input parameter for a stored procedure. <CLICK> If we use a literal as the Content Provider, we do not define a CIS resource in the FROM clause. <CLICK> We execute the view, and the data is returned as a SQL result set.

20 Demo: JSON_Table Query with Properties
In addition to retrieving data columns, we can also use JSON_TABLE to retrieve properties from a JSON structure. Here we ask for the JSON key, aliased as “property,” and value aliased as “propValue.” <CLICK> When we execute the view, both column names and values are returned.

21 Demo: JSON_Table Development Aids
The web site jsonpath.curiousconcept.com provides valuable resources for developers using JSON. If you want to verify the PATH statements you are developing for a JSON_TABLE query, you can test them here. The site also contains learning materials and coding examples. We have used CIS’s JSON_TABLE feature to retrieve JSON data from a web service and flatten it into a relational result set. We have also flattened a JSON literal, and seen how properties can be extracted from a JSON structure. Our demo is complete.

22 Agenda What is it and why does it matter? How-to Summary
Let’s summarize what we have seen in this tutorial.

23 Summary: Definition JSON_TABLE Queries
JSON: JavaScript Object Notation Widely used to collect and transfer data, especially via the Web Hierarchical format, but less verbose than XML JSON_TABLE enables queries that return results in table format JSON stands for JavaScript Object notation. It is a structuring convention for data. JSON files are widely used to collect and transfer data, especially via the web. JSON organizes data in a hierarchical format that is analogous to XML, but less verbose. JSON_TABLE functionality in CIS enables queries that read data in JSON format and return results in tables that can then be joined with other data in CIS.

24 Summary: Benefits JSON_TABLE Queries
Enables JOINS of JSON structures with relational data Many web service APIs return JSON JSON_TABLE functionality is important to our customers because it enables them to create virtual views and procedures that join JSON data with relational data from other data sources. JSON is an especially popular format for data returned by web services, and is becoming increasingly important for enterprise needs.

25 Summary: Key Take-aways
JSON_TABLE Use is optional. Automatic conversion to XML is still available. You can query data from a CIS resource or from a literal You can query both values and properties. As you work with JSON_TABLE queries in CIS, keep these key takeaways in mind. JSON_TABLE is not the only way to work with JSON in CIS. You can always have the CIS data source convert it automatically to XML, and then transform the XML using one of CIS’s transformation editors. The JSON you query can come from a CIS resource, or it can be a literal. In addition to querying data values, you can also query JSON properties.

26 Summary: What’s next? Use your knowledge to work with JSON data from many different sources Leverage your knowledge to convert JSON to XML Learn to use the CIS Transformation Editors After completing this tutorial, you are ready to begin using JSON_TABLE in your Data Virtualization projects. Use your knowledge to work with JSON data from many different sources. Leverage your knowledge to access JSON data and have CIS automatically convert it to XML. Learn to work with disparate data structures using the CIS Transformation Editors. Thank you.

27


Download ppt "Data Virtualization Tutorial: JSON_TABLE Queries"

Similar presentations


Ads by Google