Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH deploy build #136

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# jupyterlab-sql-editor

## User Guide

A user guide is hosted [here](https://cybercentrecanada.github.io/jupyterlab-sql-editor/).

## Installation

Follow the installation instructions in [CONTRIBUTING](./CONTRIBUTING.md)
Expand Down
9 changes: 9 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,12 @@ stages:
pip install twine
python -m twine upload --skip-existing -r "cccs-pypi" --config-file $(PYPIRC_PATH) $(Pipeline.Workspace)/dist/* --verbose
displayName: 'Publish artifact to PyPI.'
- job: PublishDocumentationToGithub
dependsOn: BuildPythonArtifact
steps:
- checkout: self
persistCredentials: true
- script: |
pip install mkdocs
mkdocs gh-deploy --force
displayName: 'Publish documentation site to GitHub.'
67 changes: 36 additions & 31 deletions example/Spark.ipynb → docs/example/SparkConfigurationUsage.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "c9b06840",
"metadata": {},
"source": [
"# Configuration and Usage"
]
},
{
"cell_type": "code",
"execution_count": 1,
Expand All @@ -15,7 +23,7 @@
},
"outputs": [],
"source": [
"from pyspark.sql import SparkSession"
"from pyspark.sql import SparkSession\n"
]
},
{
Expand Down Expand Up @@ -44,7 +52,7 @@
"id": "5fe87250-6936-4de6-bacf-0490a5812516",
"metadata": {},
"source": [
" Normally IPython only displays the output of the last statement. However it can be handy to run multiple sql magics in a single cell and see the output of each execution. Setting `ast_node_interactivity` to `all` will enable that.\n"
"Normally IPython only displays the output of the last statement. However it can be handy to run multiple sql magics in a single cell and see the output of each execution. Setting `ast_node_interactivity` to `all` will enable that.\n"
]
},
{
Expand All @@ -63,7 +71,7 @@
"outputs": [],
"source": [
"from IPython.core.interactiveshell import InteractiveShell\n",
"InteractiveShell.ast_node_interactivity = 'all'"
"InteractiveShell.ast_node_interactivity = 'all'\n"
]
},
{
Expand All @@ -82,7 +90,7 @@
},
"outputs": [],
"source": [
"%load_ext jupyterlab_sql_editor.ipython_magic.sparksql"
"%load_ext jupyterlab_sql_editor.ipython_magic.sparksql\n"
]
},
{
Expand All @@ -101,7 +109,7 @@
"outputs": [],
"source": [
"%config SparkSql.cacheTTL=3600\n",
"%config SparkSql.outputFile=\"/tmp/sparkdb.schema.json\""
"%config SparkSql.outputFile=\"/tmp/sparkdb.schema.json\"\n"
]
},
{
Expand Down Expand Up @@ -143,7 +151,7 @@
"source": [
"df = spark.read.json(\"file:/path/to/contacts.json\")\n",
"df.createOrReplaceTempView(\"CONTACTS_TABLE\")\n",
"df.printSchema()"
"df.printSchema()\n"
]
},
{
Expand Down Expand Up @@ -179,7 +187,7 @@
"source": [
"df = spark.read.json(\"file:/path/to/conversations.json\")\n",
"df.createOrReplaceTempView(\"MESSAGES_TABLE\")\n",
"df.printSchema()"
"df.printSchema()\n"
]
},
{
Expand Down Expand Up @@ -207,7 +215,7 @@
}
],
"source": [
"%sparksql --refresh all"
"%sparksql --refresh all\n"
]
},
{
Expand Down Expand Up @@ -280,7 +288,7 @@
}
],
"source": [
"%sparksql SHOW TABLES"
"%sparksql SHOW TABLES\n"
]
},
{
Expand Down Expand Up @@ -563,15 +571,20 @@
"SELECT\n",
" *\n",
"FROM\n",
" contacts_table AS con"
" contacts_table AS con\n"
]
},
{
"cell_type": "markdown",
"id": "07b3ac2f-3750-4c24-84e7-27c61d3a131d",
"metadata": {},
"source": [
"# Create a temporary view with the --view option"
"# Efficient query result reuse across cells\n",
"\n",
"A popular use-case is about capturing the output of a cell and use it later in another query. This can be done using a view. Here are the steps required to create a view and then referencing it \n",
"vi `sparksql`.\n",
"\n",
"## Create a temporary view with the --view option"
]
},
{
Expand Down Expand Up @@ -601,7 +614,7 @@
"source": [
"%%sparksql --view the_exploded_table --output skip\n",
"SELECT\n",
" *, \n",
" *,\n",
" explode(con.phoneNumbers) as phoneNumber\n",
"FROM\n",
" contacts_table AS con\n"
Expand Down Expand Up @@ -678,15 +691,15 @@
}
],
"source": [
"%sparksql SHOW TABLES"
"%sparksql SHOW TABLES\n"
]
},
{
"cell_type": "markdown",
"id": "4f145195-e8c9-4771-a4ae-0ffbe479234c",
"metadata": {},
"source": [
"# Use temporary view in subsequent queries with autocomplet suggestions"
"## Use temporary view in subsequent queries with autocomplete suggestions"
]
},
{
Expand Down Expand Up @@ -1073,7 +1086,7 @@
"source": [
"%%sparksql --dataframe the_exploded_dataframe --output skip\n",
"SELECT\n",
" *, \n",
" *,\n",
" explode(con.phoneNumbers) as phoneNumber\n",
"FROM\n",
" contacts_table AS con\n"
Expand Down Expand Up @@ -1116,7 +1129,7 @@
}
],
"source": [
"the_exploded_dataframe.select('phoneNumber').show()"
"the_exploded_dataframe.select('phoneNumber').show()\n"
]
},
{
Expand Down Expand Up @@ -1173,7 +1186,7 @@
" contacts_table AS con\n",
"--end-sparksql\n",
"'''\n",
"print(sql)"
"print(sql)\n"
]
},
{
Expand All @@ -1187,13 +1200,13 @@
"sql = '''\n",
"--start-sparksql\n",
"SELECT\n",
" *, \n",
" *,\n",
" explode(con.phoneNumbers) as phoneNumber\n",
"FROM\n",
" contacts_table AS con\n",
"--end-sparksql\n",
"'''\n",
"print(sql)"
"print(sql)\n"
]
},
{
Expand Down Expand Up @@ -1225,7 +1238,7 @@
}
],
"source": [
"spark.sql(sql).show()"
"spark.sql(sql).show()\n"
]
},
{
Expand Down Expand Up @@ -1290,7 +1303,7 @@
}
],
"source": [
"%%sparksql?"
"%%sparksql?\n"
]
},
{
Expand Down Expand Up @@ -1389,7 +1402,7 @@
" TRANSFORM(SEQUENCE(1, 512), x -> rand()) AS data -- array of 512 floats\n",
"FROM\n",
"RANGE\n",
" (1, 400000, 1, 100) \n",
" (1, 400000, 1, 100)\n",
"UNION\n",
"SELECT\n",
" id,\n",
Expand All @@ -1401,7 +1414,7 @@
" TRANSFORM(SEQUENCE(1, 512), x -> rand()) AS data -- array of 512 floats\n",
"FROM\n",
"RANGE\n",
" (1, 40000, 1, 100) \n"
" (1, 40000, 1, 100)\n"
]
},
{
Expand Down Expand Up @@ -1484,14 +1497,6 @@
" contacts_table AS con\n",
" INNER JOIN messages_table AS mes ON mes.`first Name` = con.`first Name`\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "39fbee24-f69b-474a-903d-bf38d170ee0d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
24 changes: 8 additions & 16 deletions example/SparkDataframe.ipynb → docs/example/SparkDataframe.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"import ipywidgets as widgets\n",
"out = widgets.Output()\n",
"with out:\n",
" spark = SparkSession.builder.getOrCreate()"
" spark = SparkSession.builder.getOrCreate()\n"
]
},
{
Expand All @@ -37,7 +37,7 @@
],
"source": [
"df = spark.sql(\"SELECT id, uuid() FROM RANGE (1, 1000)\")\n",
"df"
"df\n"
]
},
{
Expand All @@ -51,7 +51,7 @@
"source": [
"from jupyterlab_sql_editor.ipython.sparkdf import register_display\n",
"from jupyterlab_sql_editor.outputters.outputters import _display_results\n",
"register_display()"
"register_display()\n"
]
},
{
Expand Down Expand Up @@ -114,7 +114,7 @@
"source": [
"# change default display behaviour\n",
"df = spark.sql(\"SELECT id, uuid() FROM RANGE (1, 1000)\")\n",
"df"
"df\n"
]
},
{
Expand All @@ -126,7 +126,7 @@
},
"outputs": [],
"source": [
"pdf = df.limit(1).toPandas()"
"pdf = df.limit(1).toPandas()\n"
]
},
{
Expand Down Expand Up @@ -156,7 +156,7 @@
],
"source": [
"# _display_results lets you configure the output\n",
"_display_results(pdf, output=\"html\", show_nonprinting=False)"
"_display_results(pdf, output=\"html\", show_nonprinting=False)\n"
]
},
{
Expand All @@ -181,7 +181,7 @@
}
],
"source": [
"_display_results(pdf, output=\"text\")"
"_display_results(pdf, output=\"text\")\n"
]
},
{
Expand Down Expand Up @@ -210,16 +210,8 @@
],
"source": [
"df = spark.read.json(\"file:/path/to/contacts.json\")\n",
"_display_results(pdf, output=\"json\")"
"_display_results(pdf, output=\"json\")\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1447b3e6-955b-4269-bc04-6395a9673036",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "8ba62d82",
"metadata": {},
"source": [
"# Escaping Control Characters"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -13,7 +21,7 @@
"\n",
"spark = SparkSession.builder.getOrCreate()\n",
"\n",
"%load_ext jupyterlab_sql_editor.ipython_magic.sparksql"
"%load_ext jupyterlab_sql_editor.ipython_magic.sparksql\n"
]
},
{
Expand Down Expand Up @@ -53,7 +61,7 @@
" '\\\\\\\\t' AS two_backslash_and_t,\n",
" '\\\\\\\\\\t' AS two_backslash_and_tab\n",
"--end-sparksql\n",
"''').show()"
"''').show()\n"
]
},
{
Expand Down Expand Up @@ -191,14 +199,6 @@
" '\\\\\\\\t' AS two_backslash_and_t,\n",
" '\\\\\\\\\\t' AS two_backslash_and_tab\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "383afdca",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Loading
Loading