SQL v.Next Gets Native Python in SQL Server

,

The next version of SQL Server is in early preview and there is a new feature that is going to be very useful for large enterprises that want to run Big Data Clusters and perform additional data science tasks. Instead of embedding Python code in a string and submitting it to the Launchpad engine, we will now be able to actually write Python functions and compile them as native stored procedures.

That's right, the early, early access shows that Python code will natively be able to be compiled and run, similar to how T-SQL can run now. Instead of putting Python code into a string and then passing a string to the Launchpad, you can just write Python. Azure Data Studio (ADS) is being enhanced right now to allow this to work, and when the code is submitted to SQLServer, the compiler will interpret the first part of the code and determine if this is T-SQL or Python and pass this to the appropriate compiler.

This means you can just write code like this and submit it to a SQL Server connection.

python in ads

This may dramatically change the way we code in the future, and certainly will make data scientists happy.

Limitations

There are restrictions to this. First, you can only submit a Python function, and only one in a batch. Second, and this is currently a limitation, your module will be named dbo, which does limit the usefulness initially. Perhaps this is an early access issue, but for now, you can't import any custom modules. You can access any of the modules that are bundled with the base Python distribution from python.org. As of now, that's the 3.8.x version. I'm sure that will rev by the time SQL Server releases, but that's the case now.

You are also limited to accessing tables that are in the dbo schema. For many of us, this isn't an issue, but I'm sure this will limit some. I'm sure this will be resolved later, but for now, this is likely an issue because of the module limitations for your code.

I'm also not sure if this will be in SSMS. So far that question is regularly dodged, but my guess would be no. I'm not even sure you can open a Python function under the Programmability folder in Object Explorer. It hasn't worked in early testing, and I suspect there isn't any desire to add this to SSMS.

Getting Started

You can get the bits in the Microsoft Early Access Research program, which is putting out a special build of SQL Server 2019 that includes the compiler. There are a number of steps to get started, and you do need a working installation of python already on your host, but the intention is to bundle a specific set of binaries with SQL Server once this releases.

As you might have guessed by this time, the entire story is fabricated and  made up, but it does make for a nice break in this stressful time. Stay home, wash your hands, and be healthy. Hopefully I'll get the chance to meet some of you in person at some point this year.

 

Rate

5 (3)

Share

Share

Rate

5 (3)