From eec1b6c227652dab814152cd9c48983caf4b5ba1 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 17 Aug 2025 16:22:17 +0000 Subject: [PATCH 1/2] Convert config.ipynb to Jupyter notebook format with structured cells Co-authored-by: mitsuhiro_itagaki --- config.ipynb | 131 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 92 insertions(+), 39 deletions(-) diff --git a/config.ipynb b/config.ipynb index ed00d0d..3070689 100644 --- a/config.ipynb +++ b/config.ipynb @@ -1,39 +1,92 @@ -# 📁 SQL Profiler JSON File Path Configuration -# -# Please change the JSON_FILE_PATH below to your actual file path: - -# SQLProfiler JSON file (required) -JSON_FILE_PATH = '/Workspace/Shared/AutoSQLTuning/sample.json' - -# Output file directory (required) -OUTPUT_FILE_DIR = './output' - -# 🗂️ Catalog and database configuration (used when executing EXPLAIN statements) -CATALOG = 'tpcds' -DATABASE = 'tpcds_sf1000_delta_lc' - -# 🌐 Output language setting (OUTPUT_LANGUAGE: 'ja' = Japanese, 'en' = English) -OUTPUT_LANGUAGE = 'en' - -# 🔍 EXPLAIN statement execution setting (EXPLAIN_ENABLED: 'Y' = execute, 'N' = do not execute) -EXPLAIN_ENABLED = 'Y' - -# 🐛 Debug mode setting (DEBUG_ENABLED: 'Y' = keep intermediate files, 'N' = keep final files only) -DEBUG_ENABLED = 'Y' - -# 🚀 Iterative optimization maximum attempt count settings (MAX_OPTIMIZATION_ATTEMPTS: default 3 times) -# 🔄 New design: Each attempt is clearly evaluated -# - 1st attempt (initial): Initial optimization query generation and performance verification -# - 2nd attempt (single_optimization): Refined optimization based on 1st attempt results -# - 3rd attempt+ (performance_improvement): Corrected query generation based on degradation cause analysis -# - When maximum attempts reached: Use original query -# Note: This is a separate parameter from syntax error correction (MAX_RETRIES) -MAX_OPTIMIZATION_ATTEMPTS = 3 - -# Ensure output directory exists -import os -if not os.path.exists(OUTPUT_FILE_DIR): - os.makedirs(OUTPUT_FILE_DIR, exist_ok=True) - print(f"📁 Created output directory: {OUTPUT_FILE_DIR}") -else: - print(f"📁 Using output directory: {OUTPUT_FILE_DIR}")# Cell 3 placeholder# Cell 2 placeholder# Cell 1 placeholder# SQL Profiler Configuration Notebook \ No newline at end of file +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Cell 1 - Introduction\n", + "print(\"SQL Profiler Configuration Notebook\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Cell 2 - Placeholder\n", + "pass" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Cell 3 - Placeholder\n", + "pass" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# \ud83d\udcc1 SQL Profiler JSON File Path Configuration\n", + "\n", + "# SQLProfiler JSON file (required)\n", + "JSON_FILE_PATH = '/Workspace/Shared/AutoSQLTuning/sample.json'\n", + "\n", + "# Output file directory (required)\n", + "OUTPUT_FILE_DIR = './output'\n", + "\n", + "# \ud83d\udd0d EXPLAIN statement execution setting (EXPLAIN_ENABLED: 'Y' = execute, 'N' = do not execute)\n", + "EXPLAIN_ENABLED = 'Y'\n", + "\n", + "# \ud83d\uddc2\ufe0f Catalog and database configuration (used when executing EXPLAIN statements)\n", + "CATALOG = 'tpcds'\n", + "DATABASE = 'tpcds_sf1000_delta_lc'\n", + "\n", + "# \ud83c\udf10 Output language setting (OUTPUT_LANGUAGE: 'ja' = Japanese, 'en' = English)\n", + "OUTPUT_LANGUAGE = 'en'\n", + "\n", + "# \ud83d\udc1b Debug mode setting (DEBUG_ENABLED: 'Y' = keep intermediate files, 'N' = keep final files only)\n", + "DEBUG_ENABLED = 'N'\n", + "\n", + "# \ud83d\ude80 Iterative optimization maximum attempt count settings (MAX_OPTIMIZATION_ATTEMPTS: default 3 times)\n", + "# \ud83d\udd04 New design: Each attempt is clearly evaluated\n", + "# - 1st attempt (initial): Initial optimization query generation and performance verification\n", + "# - 2nd attempt (single_optimization): Refined optimization based on 1st attempt results\n", + "# - 3rd attempt+ (performance_improvement): Corrected query generation based on degradation cause analysis\n", + "# - When maximum attempts reached: Use original query\n", + "# Note: This is a separate parameter from syntax error correction (MAX_RETRIES)\n", + "MAX_OPTIMIZATION_ATTEMPTS = 3\n", + "\n", + "# Ensure output directory exists\n", + "import os\n", + "if not os.path.exists(OUTPUT_FILE_DIR):\n", + " os.makedirs(OUTPUT_FILE_DIR, exist_ok=True)\n", + " print(f\"\ud83d\udcc1 Created output directory: {OUTPUT_FILE_DIR}\")\n", + "else:\n", + " print(f\"\ud83d\udcc1 Using output directory: {OUTPUT_FILE_DIR}\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "name": "python", + "version": "3.8.0" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file From 0f1e81f1107c65b1a408a8548128685eb255ae6b Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 17 Aug 2025 16:26:25 +0000 Subject: [PATCH 2/2] Refactor config.ipynb to plain Python script with configuration settings Co-authored-by: mitsuhiro_itagaki --- config.ipynb | 129 +++++++++++++++------------------------------------ 1 file changed, 37 insertions(+), 92 deletions(-) diff --git a/config.ipynb b/config.ipynb index 3070689..4d51b8e 100644 --- a/config.ipynb +++ b/config.ipynb @@ -1,92 +1,37 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Cell 1 - Introduction\n", - "print(\"SQL Profiler Configuration Notebook\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Cell 2 - Placeholder\n", - "pass" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Cell 3 - Placeholder\n", - "pass" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# \ud83d\udcc1 SQL Profiler JSON File Path Configuration\n", - "\n", - "# SQLProfiler JSON file (required)\n", - "JSON_FILE_PATH = '/Workspace/Shared/AutoSQLTuning/sample.json'\n", - "\n", - "# Output file directory (required)\n", - "OUTPUT_FILE_DIR = './output'\n", - "\n", - "# \ud83d\udd0d EXPLAIN statement execution setting (EXPLAIN_ENABLED: 'Y' = execute, 'N' = do not execute)\n", - "EXPLAIN_ENABLED = 'Y'\n", - "\n", - "# \ud83d\uddc2\ufe0f Catalog and database configuration (used when executing EXPLAIN statements)\n", - "CATALOG = 'tpcds'\n", - "DATABASE = 'tpcds_sf1000_delta_lc'\n", - "\n", - "# \ud83c\udf10 Output language setting (OUTPUT_LANGUAGE: 'ja' = Japanese, 'en' = English)\n", - "OUTPUT_LANGUAGE = 'en'\n", - "\n", - "# \ud83d\udc1b Debug mode setting (DEBUG_ENABLED: 'Y' = keep intermediate files, 'N' = keep final files only)\n", - "DEBUG_ENABLED = 'N'\n", - "\n", - "# \ud83d\ude80 Iterative optimization maximum attempt count settings (MAX_OPTIMIZATION_ATTEMPTS: default 3 times)\n", - "# \ud83d\udd04 New design: Each attempt is clearly evaluated\n", - "# - 1st attempt (initial): Initial optimization query generation and performance verification\n", - "# - 2nd attempt (single_optimization): Refined optimization based on 1st attempt results\n", - "# - 3rd attempt+ (performance_improvement): Corrected query generation based on degradation cause analysis\n", - "# - When maximum attempts reached: Use original query\n", - "# Note: This is a separate parameter from syntax error correction (MAX_RETRIES)\n", - "MAX_OPTIMIZATION_ATTEMPTS = 3\n", - "\n", - "# Ensure output directory exists\n", - "import os\n", - "if not os.path.exists(OUTPUT_FILE_DIR):\n", - " os.makedirs(OUTPUT_FILE_DIR, exist_ok=True)\n", - " print(f\"\ud83d\udcc1 Created output directory: {OUTPUT_FILE_DIR}\")\n", - "else:\n", - " print(f\"\ud83d\udcc1 Using output directory: {OUTPUT_FILE_DIR}\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.8.0" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} \ No newline at end of file +# 📁 SQL Profiler JSON File Path Configuration + +# SQLProfiler JSON file (required) +JSON_FILE_PATH = '/Workspace/Shared/AutoSQLTuning/sample.json' + +# Output file directory (required) +OUTPUT_FILE_DIR = './output' + +# 🔍 EXPLAIN statement execution setting (EXPLAIN_ENABLED: 'Y' = execute, 'N' = do not execute) +EXPLAIN_ENABLED = 'Y' + +# 🗂️ Catalog and database configuration (used when executing EXPLAIN statements) +CATALOG = 'tpcds' +DATABASE = 'tpcds_sf1000_delta_lc' + +# 🌐 Output language setting (OUTPUT_LANGUAGE: 'ja' = Japanese, 'en' = English) +OUTPUT_LANGUAGE = 'en' + +# 🐛 Debug mode setting (DEBUG_ENABLED: 'Y' = keep intermediate files, 'N' = keep final files only) +DEBUG_ENABLED = 'N' + +# 🚀 Iterative optimization maximum attempt count settings (MAX_OPTIMIZATION_ATTEMPTS: default 3 times) +# 🔄 New design: Each attempt is clearly evaluated +# - 1st attempt (initial): Initial optimization query generation and performance verification +# - 2nd attempt (single_optimization): Refined optimization based on 1st attempt results +# - 3rd attempt+ (performance_improvement): Corrected query generation based on degradation cause analysis +# - When maximum attempts reached: Use original query +# Note: This is a separate parameter from syntax error correction (MAX_RETRIES) +MAX_OPTIMIZATION_ATTEMPTS = 3 + +# Ensure output directory exists +import os +if not os.path.exists(OUTPUT_FILE_DIR): + os.makedirs(OUTPUT_FILE_DIR, exist_ok=True) + print(f"📁 Created output directory: {OUTPUT_FILE_DIR}") +else: + print(f"📁 Using output directory: {OUTPUT_FILE_DIR}")