descriptions

This commit is contained in:
CC
2026-10-18 23:26:25 +01:00
parent 72b501a5ab
commit dbcbad6d64
4 changed files with 545 additions and 2 deletions

View File

@@ -24,9 +24,9 @@
"source": [
" ## Extract (Load in) ##\n",
"def start_spark(app_name):\n",
" \"\"\"Initialize and return a SparkSession with the PostgreSQL JDBC driver.\"\"\"\n",
" jar_path = str(Path.cwd() / \"postgresql.jar\")\n",
" spark = SparkSession.builder.appName(app_name).config(\"spark.jars\", jar_path).config(\"spark.driver.extraClassPath\", jar_path).getOrCreate()\n",
" spark.log.level(\"ERROR\")\n",
" return spark\n",
"\n",
"def get_jdbc_config():\n",
@@ -56,6 +56,7 @@
" return url, properties\n",
"\n",
"def read_jdbc(spark, table_name):\n",
" \"\"\"Read a table from Postgres via JDBC into a Spark DataFrame.\"\"\"\n",
" url, properties = get_jdbc_config()\n",
" return spark.read.jdbc(url=url, table=table_name, properties=properties)\n",
"\n",