How to Integrate Google Cloud Spanner with Denodo
Total Page:16
File Type:pdf, Size:1020Kb
How to integrate Google Cloud Spanner with Denodo Revision 20210421 NOTE This document is confidential and proprietary of Denodo Technologies. No part of this document may be reproduced in any form by any means without prior written authorization of Denodo Technologies. Copyright © 2021 Denodo Technologies Proprietary and Confidential How to integrate Google Cloud Spanner with Denodo 20210421 2 of 15 CONTENTS 1 INTRODUCTION.................................................................2 1.1 SAMPLE GOOGLE CLOUD SPANNER DATABASE.................................3 2 CREATING A SERVICE ACCOUNT AND KEY IN GOOGLE CLOUD SPANNER............................................................................4 3 CONNECTING TO GOOGLE CLOUD SPANNER USING THE JDBC DRIVER...............................................................................8 3.1 DOWNLOAD THE JDBC DRIVER........................................................8 3.2 INSTALL THE JDBC DRIVER IN THE DENODO PLATFORM....................8 3.3 CONNECT TO GOOGLE CLOUD SPANNER........................................10 3.4 CREATE A JDBC DATA SOURCE.......................................................10 3.5 CREATE A BASE VIEW...................................................................13 4 REFERENCES...................................................................16 1 INTRODUCTION Spanner is a NewSQL database designed, built, and deployed at Google for OLTP systems. It is a fully managed, mission-critical, relational database service that offers transactional consistency at a global scale, schemas, SQL, and automatic, synchronous replication for high availability. Denodo can connect to Google Cloud Spanner in order to use it as a data source and to import information. In this document, we will learn how to configure Denodo to access Google Cloud Spanner using a JDBC driver. The document is structured in two sections: ● Google Cloud Spanner configuration: Describing the required configuration steps to create a service account in Google Cloud before being able to connect through JDBC. ● Denodo configuration: Describing the required steps to create a Denodo data source and base view on top of Google Cloud Spanner. 1.1 SAMPLE GOOGLE CLOUD SPANNER DATABASE We have created a sample table called ‘Category’ inside a database of a particular instance, which contains simple data as shown. How to integrate Google Cloud Spanner with Denodo 20210421 3 of 15 Note: ‘Primary key’ is mandatory while creating a particular table in Google Cloud Spanner. Table in Google Cloud Spanner Data of ‘category’ table in Google Cloud Spanner How to integrate Google Cloud Spanner with Denodo 20210421 4 of 15 2 CREATING A SERVICE ACCOUNT AND KEY IN GOOGLE CLOUD SPANNER ● Go to the Google Cloud Platform Dashboard and click on “IAM & Admin”: ‘IAM & Admin’ option. ● Once in “IAM & Admin”, click “Service Accounts”. How to integrate Google Cloud Spanner with Denodo 20210421 5 of 15 Creating the service account. ● Fill in the form providing the name of the service account to create your account. Creating the service account. How to integrate Google Cloud Spanner with Denodo 20210421 6 of 15 ● Then, specify a ‘Role’ as per your requirement. For example, a member with ‘Cloud Spanner Database Admin’ title has full control of spanner databases. Assigning a Role. ● The next step is to generate a key to access the data. Creating the key. ● For this particular case, we will generate a JSON key that will download a file How to integrate Google Cloud Spanner with Denodo 20210421 7 of 15 with the key and the proper credentials. Generation of the key file. ● The generated JSON key file has the necessary details needed for OAuth 2.0 authentication, such as private key, client_id, auth_uri, token_uri, etc. Now we can go to the Denodo Platform to finish the configuration. 3 CONNECTING TO GOOGLE CLOUD SPANNER USING THE JDBC DRIVER 3.1 DOWNLOAD THE JDBC DRIVER First of all, download the JDBC driver to connect to Google Cloud Spanner. It can be downloaded from https://cloud.google.com/spanner/docs/jdbc-drivers. We are going to use the JDBC interface for connecting, as the recommendation is to use JDBC whenever possible due to better performance. 3.2 INSTALL THE JDBC DRIVER IN THE DENODO PLATFORM Now that we have downloaded the driver, we need to install it. Since Denodo 8.0, you can upload the JDBC driver from your client to the Denodo installation where you are How to integrate Google Cloud Spanner with Denodo 20210421 8 of 15 connected to. This can be done via the Virtual DataPort Administration Tool by navigating to File > Extension Management > Libraries > Import. In that window, you need to choose jdbc_other and provide a custom name and select the corresponding JDBC driver file that you have downloaded. How to integrate Google Cloud Spanner with Denodo 20210421 9 of 15 Note: For previous versions, the recommended way is to copy the driver jars to the folder <DENODO_HOME>/lib-external/jdbc-drivers/database name - version Later, you need to provide the 'database name - version' in the driver classpath. 3.3 CONNECT TO GOOGLE CLOUD SPANNER To connect to Google Cloud Spanner, you need to create a JDBC data source within the Denodo Platform. Then you can create the base views that will represent the Spanner tables. 3.4 CREATE A JDBC DATA SOURCE 1. Open the Denodo Design Studio or the Virtual DataPort Administration Tool, log in and go to File > New > Data source > JDBC. The configuration of a new JDBC source opens. How to integrate Google Cloud Spanner with Denodo 20210421 10 of 15 Creation of a data source. 2. Enter the connection details for your spanner database and click OK: ● Provide a name, for example ds_spanner ● Select Generic as Database adapter ● Database URL: jdbc:cloudspanner://ProjectId=<PROJECT_ID>;Instance=<instance _name>;Database=<db_name>;PvtKeyPath=<PATH_TO_CREDENTIALS_FIL E> The values for PROJECT_ID can be obtained from the credentials JSON file created above. How to integrate Google Cloud Spanner with Denodo 20210421 11 of 15 ● Under the “Advanced” option, select the Driver class path that you have uploaded previously CloudSpanner42Driver and Driver class as com.simba.cloudspanner.core.jdbc42.CloudSpanner42Driver If everything is correct, save the data source. You can verify this by clicking on Test Connection. How to integrate Google Cloud Spanner with Denodo 20210421 12 of 15 3.5 CREATE A BASE VIEW To create a base view of the tables you want to query, follow these steps: ● Switch to the tab CREATE BASE VIEW ● Click + to expand the schema name you are interested in. ● Select the tables (in this case, the base view could be ‘category’ table) you want to import. ● Click on Create Selected How to integrate Google Cloud Spanner with Denodo 20210421 13 of 15 Creation of a base view. Note: If the view is created using the ‘Create from Query’ option and has "@" and "{ " special characters in them, these characters need to be escaped with the "\" (backslash) separately. The base view is now created: The schema of the example base view. Finally, the results of our execution will look like this: How to integrate Google Cloud Spanner with Denodo 20210421 14 of 15 The results of the base view we created in our example. How to integrate Google Cloud Spanner with Denodo 20210421 15 of 15 4 REFERENCES Cloud Spanner Virtual DataPort Administration Guide: Uploading a JDBC Driver Virtual DataPort Administration Guide: JDBC Sources.