{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "14b7f3f8-0307-4fdb-a18b-1fa047e69032", "metadata": {}, "outputs": [], "source": [ "Oracle AI Data Platform v1.0\n", "\n", "Copyright © 2025, Oracle and/or its affiliates.\n", "\n", "Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/" ] }, { "cell_type": "markdown", "id": "8fddad9d", "metadata": { "type": "python" }, "source": [ "# Basic AI Data Platform SQL Notebook\n", "\n", "This notebook demonstrates basic operations in AI Data Platform, including:\n", " 1. **Data frame creation**\n", " 2. **Basic transformations with PySpark SQL**\n", " 3. **Simple visualization**\n", " \n", "# **Parameters**\n" ] }, { "cell_type": "code", "execution_count": null, "id": "1a492cee-1465-4b69-b23c-83f4861b6427", "metadata": { "execution": { "iopub.status.busy": "2025-03-23T18:57:50.497Z" }, "type": "sql" }, "outputs": [], "source": [ "%sql\n", "create catalog if not exists lake" ] }, { "cell_type": "code", "execution_count": null, "id": "4df0d26d-0aed-46f3-aa68-e286e10a9e3e", "metadata": { "execution": { "iopub.status.busy": "2025-03-23T18:53:06.359Z" }, "type": "sql" }, "outputs": [ { "data": { "text/html": [ "
OK
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%sql\n", "create schema if not exists lake.bronze" ] }, { "cell_type": "markdown", "id": "677c2ad5", "metadata": {}, "source": [ "# **1. Load Sample Data**\n", "\n", "We will create a simple DataFrame to work with." ] }, { "cell_type": "code", "execution_count": null, "id": "e37f7d36", "metadata": { "execution": { "iopub.status.busy": "2025-03-23T18:57:46.410Z" }, "type": "sql" }, "outputs": [], "source": [ "%sql\n", "CREATE TABLE IF NOT EXISTS lake.bronze.basic_tab (id INTEGER, name STRING, age INTEGER, country STRING) USING CSV;\n", "INSERT INTO lake.bronze.basic_tab VALUES (1, 'Alice', 34, 'USA');\n", "INSERT INTO lake.bronze.basic_tab VALUES (2, 'Bob', 45, 'Canada');\n", "INSERT INTO lake.bronze.basic_tab VALUES (3, 'Charlie', 29, 'UK');\n", "INSERT INTO lake.bronze.basic_tab VALUES (4, 'David', 41, 'Germany');\n", "SELECT * from lake.bronze.basic_tab;" ] }, { "cell_type": "markdown", "id": "255c3f8c", "metadata": {}, "source": [ "# **2. Perform Basic Transformations**\n", "\n", "Let's calculate the average age." ] }, { "cell_type": "code", "execution_count": 1, "id": "c08b1f9f", "metadata": { "execution": { "iopub.status.busy": "2025-03-23T18:57:09.041Z" }, "type": "sql" }, "outputs": [], "source": [ "%sql\n", "select AVG(age) average_age from lake.bronze.basic_tab" ] }, { "cell_type": "markdown", "id": "ec6336f3", "metadata": {}, "source": [ "# **3 Visualize the Data**\n", "\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "f87419db", "metadata": { "execution": { "iopub.status.busy": "2025-03-23T18:57:01.554Z" } }, "outputs": [], "source": [ "df=spark.sql(\"select * from lake.bronze.basic_tab\")\n", "display(df)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.12" } }, "nbformat": 4, "nbformat_minor": 5 }