<commit_before>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# IPython magic functions for Pyspark\n",
    "# Examples of shortcuts for executing SQL in Spark"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#\n",
    "# IPython magic functions to use with Pyspark and Spark SQL\n",
    "# The following code is intended as examples of shorcuts to simplify the use of SQL in pyspark\n",
    "# The defined functions are:\n",
    "#\n",
    "# %sql <statement>          - return a Spark DataFrame for lazy evaluation of the SQL\n",
    "# %sql_show <statement>     - run the SQL statement and show max_show_lines (50) lines\n",
    "# %sql_display <statement>  - run the SQL statement and display the results using a HTML table
    "#                           - this is implemented passing via Pandas and displays up to max_show_lines (50)\n",
    "# %sql_explain <statement>  - display the execution plan of the SQL statement\n",
    "#\n",
    "# Use: %<magic> for line magic or %%<magic> for cell magic.\n",
    "#\n",
    "# Author: <EMAIL>\n",
    "# September 2016\n",
    "#\n",
    "\n",
    "from IPython.core.magic import register_line_cell_magic\n",
    "\n",
    "# Configuration parameters\n",
    "max_show_lines = 50         # Limit on the number of lines to show with %sql_show and %sql_display\n",
    "detailed_explain = True     # Set to False if you want to see only the physical plan when running explain\n",
    "\n",
    "\n",
    "@register_line_cell_magic\n",
    "def sql(line, cell=None):\n",
    "    \"Return a Spark DataFrame for lazy evaluation of the sql. Use: %sql or %%sql\"\n",
    "    val = cell if cell is not None else line \n",
    "    return sqlContext.sql(val)\n",
    "\n",
    "@register_line_cell_magic\n",
    "def sql_show(line, cell=None):\n",<commit_msg>added IPython SQL magic<commit_after>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# IPython magic functions for Pyspark\n",
    "# Examples of shortcuts for executing SQL in Spark"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#\n",
    "# IPython magic functions to use with Pyspark and Spark SQL\n",
    "# The following code is intended as examples of shorcuts to simplify the use of SQL in pyspark\n",
    "# The defined functions are:\n",
    "#\n",
    "# %sql <statement>          - return a Spark DataFrame for lazy evaluation of the SQL\n",
    "# %sql_show <statement>     - run the SQL statement and show max_show_lines (50) lines\n",
    "# %sql_display <statement>  - run the SQL statement and display the results using a HTML table\n",
    "#                           - this is implemented passing via Pandas and displays up to max_show_lines (50)\n",
    "# %sql_explain <statement>  - display the execution plan of the SQL statement\n",
    "#\n",
    "# Use: %<magic> for line magic or %%<magic> for cell magic.\n",
    "#\n",
    "# Author: <EMAIL>\n",
    "# September 2016\n",
    "#\n",
    "\n",
    "from IPython.core.magic import register_line_cell_magic\n",
    "\n",
    "# Configuration parameters\n",
    "max_show_lines = 50         # Limit on the number of lines to show with %sql_show and %sql_display\n",
    "detailed_explain = True     # Set to False if you want to see only the physical plan when running explain\n",
    "\n",
    "\n",
    "@register_line_cell_magic\n",
    "def sql(line, cell=None):\n",
    "    \"Return a Spark DataFrame for lazy evaluation of the sql. Use: %sql or %%sql\"\n",
    "    val = cell if cell is not None else line \n",
    "    return sqlContext.sql(val)\n",
    "\n",
    "@register_line_cell_magic\n",
    "def sql_show(line, cell=None):\n",
{'fraction_non_alphanumeric': 0.14186762442278092, 'fraction_numerical': 0.005643919958953309, 'mean_word_length': 2.6405228758169934, 'pattern_counts': {'":': 20, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4040731', 'n_tokens_mistral': 1297, 'n_tokens_neox': 1280, 'n_words': 428}