Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions AI_ASSIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,33 @@ Record at least one point where you used an AI coding assistant (ChatGPT, Claude

## Interaction 1

- **Tool used:** (e.g. ChatGPT / Cursor / Claude)
- **Task / Problem:** (e.g. debugging dbt connection profile / writing PySpark join / configuring Job trigger)
- **Tool used:** (gemeni flash-lite)
- **Task / Problem:** debugging dbt connection profile
- **Prompt sent:**
> `___`
> ERROR:databricks.sql.backend.thrift_backend:ThriftBackend.attempt_request: Exception:

10:19:34 Databricks adapter: Connection(session-id=Unknown) - Exception while trying to create connection: Error during request to server.

Error properties: attempt=1/30, bounded-retry-delay=None, elapsed-seconds=0.07423233985900879/900.0, error-message=, http-code=404, method=OpenSession, no-retry-reason=non-retryable error, original-exception=, query-id=None, session-id=None

10:19:34 Connection test: [ERROR]


10:19:34 1 check failed:

10:19:34 dbt was unable to connect to the specified database.

The database returned the following error:


>Database Error

Database Error

Error during request to server.
- **Output provided by AI:**
> `___`
> An HTTP 404 (OpenSession not found) error during a dbt debug connection test means that the Databricks SQL driver successfully reached your server hostname, but the specific HTTP Path (http_path) pointing to your SQL Warehouse or cluster is invalid, mistyped, or pointing to a resource that no longer exists.How to Fix ItCheck your profiles.yml file (usually located in ~/.dbt/profiles.yml) and inspect the host and http_path settings. 1. Check for Common Syntax Errors in profiles.ymlNo https:// in the host: The host field should just be the domain name.❌ Incorrect: host: [https://adb-123456789.12.azuredatabricks.net](https://adb-123456789.12.azuredatabricks.net)✔️ Correct: host: adb-123456789.12.azuredatabricks.netMissing Leading Slash (/) in HTTP Path: The http_path must always begin with a forward slash. ❌ Incorrect: http_path: sql/protocolv1/o/...✔️ Correct: http_path: /sql/protocolv1/o/...2. Re-copy the HTTP Path from DatabricksIt is very easy to accidentally miss a character or copy an old cluster path that has been terminated.Log into your Databricks Workspace.Go to SQL Warehouses and click on the warehouse you want to use.Go to the Connection Details tab. Copy the HTTP Path fresh and paste it directly into your profiles.yml.3. Verify the SQL Warehouse is RunningIf the SQL Warehouse is currently Stopped, the connection will fail. Make sure the warehouse status is running/started in the Databricks UI before executing dbt debug.
- **What I kept, changed, or rejected, and why:**
> `___`
> after some back and forth it was a naming mistake inside the sql schema not the actual env schema changed it and everything worked

*(Ensure no personal passwords, Databricks tokens, or unapproved credentials are included in prompts or logged outputs.)*
28 changes: 28 additions & 0 deletions task-1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,31 @@ Add your Databricks notebook here.
- Two or three sentences on when you would choose PySpark versus dbt SQL.

See the [Week 13 assignment](https://www.notion.so/hackyourfuture/Assignment-2af50f64ffc98112b371c42a3f469749) for full requirements.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this supposed to be in the notebook? As your missing question is here and not in the notebook :)

**reference:**
from pyspark.sql import functions as F

trips = spark.read.table("hyf.nyc_yellow.raw_trips")
zones = spark.read.table("hyf.nyc_yellow.raw_zones")

**Question 1:**

borough_counts = (
trips
.join(zones, trips.pickup_location_id == zones.location_id)
.groupBy("borough")
.agg(F.count("*").alias("trip_count"))
.orderBy(F.col("trip_count").desc())
)

borough_counts.show(1)

**Question 2:**
payment_avg = (
trips
.groupBy("payment_type")
.agg(F.round(F.avg("total_amount"), 2).alias("avg_total_amount"))
.orderBy("payment_type")
)

payment_avg.show()
100 changes: 100 additions & 0 deletions task-1/pyspark_exploration.ipynb

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Total amount per payment type is missing!

Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 0,
"metadata": {
"application/vnd.databricks.v1+cell": {
"cellMetadata": {},
"finishTime": 1785326358620,
"inputWidgets": {},
"nuid": "ff04faac-5cf0-4fe7-bfcd-6abc9f8f2a16",
"showTitle": false,
"startTime": 1785326358084,
"submitTime": 1785326357672,
"tableResultSettingsMap": {},
"title": ""
}
},
"outputs": [],
"source": [
"from pyspark.sql import functions as F\n",
"\n",
"trips = spark.read.table(\"hyf.nyc_yellow.raw_trips\")\n",
"zones = spark.read.table(\"hyf.nyc_yellow.raw_zones\").select(\n",
" \"location_id\",\n",
" \"borough\",\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 0,
"metadata": {
"application/vnd.databricks.v1+cell": {
"cellMetadata": {
"byteLimit": 2048000,
"rowLimit": 10000
},
"finishTime": 1785327406693,
"inputWidgets": {},
"nuid": "78a135c8-e36c-4292-babd-f6d97f97cd5c",
"showTitle": false,
"startTime": 1785327404237,
"submitTime": 1785327403902,
"tableResultSettingsMap": {},
"title": ""
}
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"output_type": "stream",
"text": [
"+---------+----------+\n| borough|trip_count|\n+---------+----------+\n|Manhattan| 112028489|\n+---------+----------+\nonly showing top 1 row\n"
]
}
],
"source": [
"borough_counts = (\n",
" trips\n",
" .join(zones, trips.pickup_location_id == zones.location_id)\n",
" .groupBy(\"borough\")\n",
" .agg(F.count(\"*\").alias(\"trip_count\"))\n",
" .orderBy(F.col(\"trip_count\").desc())\n",
")\n",
"\n",
"borough_counts.show(1)"
]
}
],
"metadata": {
"application/vnd.databricks.v1+notebook": {
"computePreferences": null,
"dashboards": [],
"environmentMetadata": {
"base_environment": "",
"environment_version": "5"
},
"inputWidgetPreferences": null,
"language": "python",
"notebookMetadata": {
"mostRecentlyExecutedCommandWithImplicitDF": {
"commandId": -1,
"dataframes": [
"_sqldf"
]
},
"pythonIndentUnit": 4
},
"notebookName": "New Notebook 2026-07-29 13:54:03",
"widgets": {}
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
165 changes: 165 additions & 0 deletions task-2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# dbt
target/
dbt_packages/
logs/
profiles.yml
.user.yml

# System files
.DS_Store
Thumbs.db
[Dd]esktop.ini

# hyf
.hyf/score.json

# Editor and IDE settings
.vscode/
.idea/
*.iml
*.code-workspace
*.sublime-project
*.sublime-workspace
.history/
.ionide/

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.*
!.env.example

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Sveltekit cache directory
.svelte-kit/

# vitepress build output
**/.vitepress/dist

# vitepress cache directory
**/.vitepress/cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# Firebase cache directory
.firebase/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v3
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Vite logs files
vite.config.js.timestamp-*
vite.config.ts.timestamp-*

19 changes: 14 additions & 5 deletions task-2/WRITEUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,30 @@ Fill in after running `dbt build --select fct_trips --full-refresh` baseline fol

## First build (full / initial load with --full-refresh)

- **Wall-clock time:**
- **Wall-clock time: 13:51**
94.80s
- **Notes:** (optional: warehouse size, any errors you fixed)

## Second build (incremental rerun)

- **Wall-clock time:**

- **Wall-clock time:13:53**
81.36s

## Why was the second run faster?

Write two or three sentences in your own words (see the assignment for the concepts you must name):

Write two or three sentences in your own words (see the assignment for the concepts you must name): is_incremental() speeds up the process because if the table exists it wont rebuild the entire table from scratch and if its true {{this}} filter starts to work and check if there is new inserts to be modified or added
`___`

## Delta Table History (DESCRIBE HISTORY)

Paste the output or summary of `DESCRIBE HISTORY hyf.dev_yourname.fct_trips` (showing `CREATE OR REPLACE TABLE` and `MERGE` operations) or reference a screenshot:
![Alt Text](describe.png)
version,timestamp,userId,userName,operation,operationParameters,job,notebook,queryHistoryStatementId,clusterId,readVersion,isolationLevel,isBlindAppend,operationMetrics,userMetadata,engineInfo
4,2026-07-30T11:53:06.000Z,142272964130057,baderalmsaddy@gmail.com,MERGE,"{""predicate"":""[\""(trip_id#28336 <=> trip_id#28476)\""]"",""clusterBy"":""[]"",""matchedPredicates"":""[{\""actionType\"":\""update\""}]"",""statsOnLoad"":""false"",""notMatchedBySourcePredicates"":""[]"",""notMatchedPredicates"":""[{\""actionType\"":\""insert\""}]""}",null,null,01f18c0d-0da2-1778-887c-ca46c7e0c62d,null,3,WriteSerializable,false,"{""numTargetRowsCopied"":""0"",""numTargetRowsDeleted"":""0"",""numTargetBytesRemoved"":""0"",""numTargetDeletionVectorsAdded"":""0"",""numTargetRowsMatchedUpdated"":""0"",""numTargetRowsMatchedDeleted"":""0"",""numTargetRowsUpdated"":""0"",""numTargetChangeFilesAdded"":""0"",""numTargetRowsNotMatchedBySourceDeleted"":""0"",""rewriteTimeMs"":""3702"",""numTargetFilesAdded"":""0"",""numTargetBytesAdded"":""0"",""executionTimeMs"":""74496"",""materializeSourceTimeMs"":""70033"",""numTargetRowsInserted"":""0"",""numTargetDeletionVectorsUpdated"":""0"",""scanTimeMs"":""728"",""numOutputRows"":""0"",""numTargetDeletionVectorsRemoved"":""0"",""numTargetRowsNotMatchedBySourceUpdated"":""0"",""numSourceRows"":""0"",""numTargetFilesRemoved"":""0""}",null,Databricks-Runtime/18.x-aarch64-photon-scala2.13
3,2026-07-30T11:51:16.000Z,142272964130057,baderalmsaddy@gmail.com,CREATE OR REPLACE TABLE AS SELECT,"{""partitionBy"":""[]"",""clusterBy"":""[]"",""description"":null,""isManaged"":""true"",""properties"":""{\""delta.checkpoint.writeStatsAsJson\"":\""false\"",\""delta.checkpoint.writeStatsAsStruct\"":\""true\"",\""delta.parquet.compression.codec\"":\""zstd\"",\""delta.enableDeletionVectors\"":\""true\""}"",""statsOnLoad"":""true""}",null,null,01f18c0c-c1be-1515-b30a-1fb61ac6307f,null,2,WriteSerializable,false,"{""numFiles"":""64"",""numRemovedFiles"":""65"",""numRemovedBytes"":""5159027812"",""numDeletionVectorsRemoved"":""0"",""numOutputRows"":""124241246"",""numOutputBytes"":""5160528189""}",null,Databricks-Runtime/18.x-aarch64-photon-scala2.13
2,2026-07-30T11:45:23.000Z,142272964130057,baderalmsaddy@gmail.com,MERGE,"{""predicate"":""[\""(trip_id#24719 <=> trip_id#24859)\""]"",""clusterBy"":""[]"",""matchedPredicates"":""[{\""actionType\"":\""update\""}]"",""statsOnLoad"":""false"",""notMatchedBySourcePredicates"":""[]"",""notMatchedPredicates"":""[{\""actionType\"":\""insert\""}]""}",null,null,01f18c0b-f890-1e66-aa1d-5f2c56335061,null,1,WriteSerializable,false,"{""numTargetRowsCopied"":""0"",""numTargetRowsDeleted"":""0"",""numTargetBytesRemoved"":""0"",""numTargetDeletionVectorsAdded"":""0"",""numTargetRowsMatchedUpdated"":""0"",""numTargetRowsMatchedDeleted"":""0"",""numTargetRowsUpdated"":""0"",""numTargetChangeFilesAdded"":""0"",""numTargetRowsNotMatchedBySourceDeleted"":""0"",""rewriteTimeMs"":""1982"",""numTargetFilesAdded"":""0"",""numTargetBytesAdded"":""0"",""executionTimeMs"":""75613"",""materializeSourceTimeMs"":""72818"",""numTargetRowsInserted"":""0"",""numTargetDeletionVectorsUpdated"":""0"",""scanTimeMs"":""790"",""numOutputRows"":""0"",""numTargetDeletionVectorsRemoved"":""0"",""numTargetRowsNotMatchedBySourceUpdated"":""0"",""numSourceRows"":""0"",""numTargetFilesRemoved"":""0""}",null,Databricks-Runtime/18.x-aarch64-photon-scala2.13
1,2026-07-30T11:41:45.000Z,142272964130057,baderalmsaddy@gmail.com,MERGE,"{""predicate"":""[\""(trip_id#22154 <=> trip_id#22294)\""]"",""clusterBy"":""[]"",""matchedPredicates"":""[{\""actionType\"":\""update\""}]"",""statsOnLoad"":""false"",""notMatchedBySourcePredicates"":""[]"",""notMatchedPredicates"":""[{\""actionType\"":\""insert\""}]""}",null,null,01f18c0b-7800-1e38-bc8d-2bd108a77adb,null,0,WriteSerializable,false,"{""numTargetRowsCopied"":""0"",""numTargetRowsDeleted"":""0"",""numTargetBytesRemoved"":""0"",""numTargetDeletionVectorsAdded"":""0"",""numTargetRowsMatchedUpdated"":""0"",""numTargetRowsMatchedDeleted"":""0"",""numTargetRowsUpdated"":""0"",""numTargetChangeFilesAdded"":""0"",""numTargetRowsNotMatchedBySourceDeleted"":""0"",""rewriteTimeMs"":""2856"",""numTargetFilesAdded"":""0"",""numTargetBytesAdded"":""0"",""executionTimeMs"":""73312"",""materializeSourceTimeMs"":""69355"",""numTargetRowsInserted"":""0"",""numTargetDeletionVectorsUpdated"":""0"",""scanTimeMs"":""1072"",""numOutputRows"":""0"",""numTargetDeletionVectorsRemoved"":""0"",""numTargetRowsNotMatchedBySourceUpdated"":""0"",""numSourceRows"":""0"",""numTargetFilesRemoved"":""0""}",null,Databricks-Runtime/18.x-aarch64-photon-scala2.13
0,2026-07-30T11:38:34.000Z,142272964130057,baderalmsaddy@gmail.com,CREATE OR REPLACE TABLE AS SELECT,"{""partitionBy"":""[]"",""clusterBy"":""[]"",""description"":null,""isManaged"":""true"",""properties"":""{\""delta.checkpoint.writeStatsAsJson\"":\""false\"",\""delta.checkpoint.writeStatsAsStruct\"":\""true\"",\""delta.parquet.compression.codec\"":\""zstd\"",\""delta.enableDeletionVectors\"":\""true\""}"",""statsOnLoad"":""true""}",null,null,01f18c0a-f72d-1a36-a628-ffc3ee779511,null,null,WriteSerializable,false,"{""numFiles"":""65"",""numRemovedFiles"":""0"",""numRemovedBytes"":""0"",""numDeletionVectorsRemoved"":""0"",""numOutputRows"":""124241246"",""numOutputBytes"":""5159027812""}",null,Databricks-Runtime/18.x-aarch64-photon-scala2.13


`___`
Loading