Examples: Query a Table from a Delta Share and Analyze the View
Let’s assume that we are working on an inventory database where we have data about the information collected by the U.S. Census Service concerning housing in the Boston area, and we need a query that returns the maximum value of the full-value property tax.
- Create an Oracle Delta Share provider and credential:
For creating a Delta Share provider, you typically need to interact with the Delta Sharing platform, which involves creating a credential suitable for use with delta share providers. In this example, you can create
DATABRICKS_PROVIDER
.BEGIN dbms_share.create_or_replace_share_provider( provider_name=> 'DATABRICKS_PROVIDER', endpoint=> 'https://sharing.delta.io/delta-sharing'); dbms_cloud.create_credential( credential_name => 'CREDENTIAL_NAME', username => 'BEARER_TOKEN', password => '*********************************'); dbms_share.set_share_provider_credential( 'DATABRICKS_PROVIDER', 'CREDENTIAL_NAME'); END; //
The output of this procedure successfully creates a delta share provider.
- Mount a DB Share Catalog:
After creating credentials, you can mount the registered share provider from step 1 as a catalog to enable the catalog users to search and discover data from the share, and to query that data using SQL.
BEGIN dbms_catalog.mount_share( catalog_name=>'databricks', share_provider=>'databricks_provider', share_name=>'delta_sharing'); END; /
The output of this procedure successfully creates a catalog integration that enables the Catalog tool to query tables stored in Databricks.
- Run a simple query:
You can now run a simple query on the table:
select max(tax) from "DEFAULT"."BOSTON-HOUSING"@catalogname;
The output returns the maximum value of the full value of the property tax rate present in the table.
MAX(TAX) ---------- 711
Parent topic: Query Remote Catalogs and Databases