{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# SQL TO KQL Conversion (Experimental)\n", "\n", "The `sql_to_kql` module is a simple converter to KQL based on [moz_sql_parser](https://github.com/DrDonk/moz-sql-parser).\n", "It is an experimental feature built to help us convert a few queries but we\n", "thought that it was useful enough to include in MSTICPy.\n", "\n", "You must have msticpy installed along with the moz_sql_parser package to run this notebook:\n", "```\n", "!pip install --upgrade msticpy[sql2kql]\n", "```\n", "\n", "It supports a subset of ANSI SQL-92 which includes the following:\n", "- SELECT (including column renaming and functions)\n", "- FROM (including from subquery)\n", "- WHERE (common string and int operations, LIKE, some common functions)\n", "- LIMIT\n", "- UNION, UNION ALL\n", "- JOIN - only tested for relatively simple join expressions\n", "- GROUP BY\n", "- SQL Comments (ignored)\n", "\n", "It does not support HAVING, multiple SQL statements or anything complex like Common Table Expressions.\n", "\n", "It does support a few additional Spark SQL extensions like RLIKE.\n", "\n", "## Caveat Emptor!\n", "This module is included in MSTICPy in the hope that it might be useful to others.\n", "We do not intend to expand its capabilities.\n", "\n", "It is also not guaranteed to produce perfectly-executing KQL - there will likely\n", "be things that you have to fix up in the output query. \n", "You will, for example, nearly always need change\n", "the names of the fields used since the source data tables are unlikely\n", "to exactly match the schema of your Kusto/Azure Sentinel target.\n", "\n", "The module does include an elementary table name mapping function that we\n", "demonstrate below.\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Processing imports....\n", "Checking configuration....\n", "No errors found.\n", "No warnings found.\n", "Setting notebook options....\n" ] }, { "data": { "text/html": [ "