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

Add do-nothing SQL kernel to the builtin kernels in order to enable SQL language coloring #1105

Closed
wants to merge 5 commits into from

Conversation

corivera
Copy link
Member

This change adds a do-nothing SQL kernel that can be used to enable language coloring for SQL code. This is required because we can only define language grammars for fixed kernel names, but MSSQL kernel names are user-defined via the connect magic command, and thus aren't known ahead of time. The default SQL kernel displays a help message on execute if no actual SQL kernel exists, and does nothing otherwise. I also added a Language field to the base Kernel class so that we can better determine a kernel's capabilities without relying on its name.

Additionally, I incorporated the language grammar changes from @brettfo's PR here, for sake of completeness: #1099

@@ -36,7 +36,7 @@ public class MsSqlKernel :
public MsSqlKernel(
string name,
string connectionString,
MsSqlServiceClient client) : base(name)
MsSqlServiceClient client) : base(name, "SQL")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be "T-SQL" or "MSSQL" or something more specific.

@@ -45,6 +45,29 @@ public static Kernel FindKernel(this Kernel kernel, string name)
};
}

public static Kernel FindKernel(this Kernel kernel, Func<Kernel, bool> selector)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should return IEnumerable<Kernel> since there can be more than one that matches.

It would be more straightforward to use VisitSubkernels and avoid looking at the ChooseKernelDirectives.


Once installed, you can find more info about creating a SQL kernel and running queries by running the following help command:
#!connect mssql -h
");
Copy link
Contributor

@jonsequitur jonsequitur Feb 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the message is emitted as "text/markdown" we can include a link to the package on NuGet.org, and people can find additional information that way.

A SQL kernel is not currently defined.

SQL kernels are provided as part of the Microsoft.DotNet.Interactive.SqlServer package, which can be installed by using the following nuget command:
#r Microsoft.DotNet.Interactive.SqlServer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The #r directive should be updated to #r "nuget:Microsoft.DotNet.Interactive.SqlServer,*-*".

Formatted as Markdown, you'll want:

image

@corivera corivera closed this Feb 26, 2021
@corivera corivera deleted the corivera/addDefaultSqlKernel branch February 26, 2021 21:39
@corivera
Copy link
Member Author

Closing this PR since @colombod is working on a different solution for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants