microsoft / jupyter-Kqlmagic

Extension (Magic) to Jupyter notebook and Jupyter lab, that enable notebook experience working with Kusto, ApplicationInsights, and LogAnalytics data.
Other
85 stars 31 forks source link

Fix parameterizer to better handle strings and to also handle pandas … #50

Closed miflower closed 4 years ago

miflower commented 4 years ago

Currently strings are enclosed in single quotes before passing them on to the request. By using repr we can ensure that both single and double quotes are properly handled. Enables following scenario:

x = "Zombie's Hand"
%%kql
let _x = x;
datatable(Name: string, Cute: bool) [
"Squirrel", true,
"Zombie's Hand", false
]
| where Name == _x

Second portion is to handle a pandas Series as a list rather than a string, this enables a lot of scenarios when Series are being used in different areas and not having to convert them into lists beforehand.

Continuation from previous snippet:

cute_names = _kql_raw_result.Name
%%kql
let _c = cute_names;
datatable(Name: string, IsAlive: bool) [
"Squirrel", true,
"Zombie's Hand", false
]
| where Name in (_c)
mbnshtck commented 4 years ago

both suggestion are very good. Will merge and publish in next version. Thank you for this contribution.

Michael

Get Outlook for Androidhttps://aka.ms/ghei36


From: miflower notifications@github.com Sent: Monday, January 6, 2020 10:01:44 PM To: microsoft/jupyter-Kqlmagic jupyter-Kqlmagic@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [microsoft/jupyter-Kqlmagic] Fix parameterizer to better handle strings and to also handle pandas … (#50)

Currently strings are enclosed in single quotes before passing them on to the request. By using repr we can ensure that both single and double quotes are properly handled. Enables following scenario:

x = "Zombie's Hand" %%kql let _x = x; datatable(Name: string, Cute: bool) [ "Squirrel", true, "Zombie's Hand", false ] | where Name == _x

Second portion is to handle a pandas Series as a list rather than a string, this enables a lot of scenarios when Series are being used in different areas and not having to convert them into lists beforehand.

Continuation from previous snippet:

cute_names = _kql_raw_result.Name %%kql let _c = cute_names; datatable(Name: string, IsAlive: bool) [ "Squirrel", true, "Zombie's Hand", false ] | where Name in (_c)


You can view, comment on, or merge this pull request online at:

https://github.com/microsoft/jupyter-Kqlmagic/pull/50https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fjupyter-Kqlmagic%2Fpull%2F50&data=02%7C01%7Cmichabin%40microsoft.com%7C8c2f979421f04682a46c08d792e341a4%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637139377065535876&sdata=%2F6DRnXpwQs7aauI2%2BbsbqI%2FUNJbJ7hQS8eevGSkgups%3D&reserved=0

Commit Summary

File Changes

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fjupyter-Kqlmagic%2Fpull%2F50%3Femail_source%3Dnotifications%26email_token%3DACGKLXV7FKNGKEMD6EO3YHLQ4OE2RA5CNFSM4KDJYIIKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IEJ66EA&data=02%7C01%7Cmichabin%40microsoft.com%7C8c2f979421f04682a46c08d792e341a4%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637139377065555862&sdata=fPGytyH5XIVV5csF%2BEmJqxlrODbtC7lLfCvsPNrdBbw%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACGKLXXJ5CPGGRZAENXRZMDQ4OE2RANCNFSM4KDJYIIA&data=02%7C01%7Cmichabin%40microsoft.com%7C8c2f979421f04682a46c08d792e341a4%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637139377065565855&sdata=0V2pvIforP%2BHtrnQz0wGbdYrL0Ts0VmzpFzYwTqinAI%3D&reserved=0.