Advent of 2023, Day 7 – SQL commands in SQL Analytics endpoint

In this Microsoft Fabric series:

  1. Dec 01: What is Microsoft Fabric?
  2. Dec 02: Getting started with Microsoft Fabric
  3. Dec 03: What is lakehouse in Fabric?
  4. Dec 04: Delta lake and delta tables in Microsoft Fabric
  5. Dec 05: Getting data into lakehouse
  6. Dec 06: SQL Analytics endpoint

Let’s explore the SQL commands that are available in SQL Analytics endpoint. And it should be easier to check, what is currently not supported and should also be dependant on the license plan.

In addition, I would like to emphasise, that Fabric Warehouse and Fabric SQL Analytics endpoints are not the same services, hence commands that will work in Warehouse, might not work in SQL Analytics!

What is not supported

CREATE TABLE can fail:

CREATE table Advent2023.dbo.test (
ID INT NOT NULL 
,SomeTExt VARCHAR(100) NOT NULL
)

You will need to create a delta table in Lakehouse workspace (using e.g.: notebooks and SparkSQL). On the other hand, create a view or creating a view with schemabinding is not a problem:

DROP VIEW IF EXISTS dbo.testView_sb
CREATE VIEW  dbo.testView_sb  
WITH SCHEMABINDING  
AS  
SELECT 
[Petal.Length], [Species] 
from dbo.iris_data

The famous CTAS – CREATE TABLE AS SELECT, will also not work in SQL Analytics. These will for sure work in Fabric warehouse to save on copying and moving data.

Creating index/ indexes is also not supported and will be terminated:

CREATE CLUSTERED INDEX index1 ON Advent2023.dbo.iris_species (ID);

Synonyms are also not supported:

CREATE SYNONYM iris_rozice
FOR Advent2023.dbo.iris_data;

Also not supported is CREATE RULE / DEFAULT. In addition, you will not be able to TRUNCATE the table

You get the gist, and there are some other limitations; computed columns, indexed views, any kind of indexes, partitioned tables, triggers, user-defined types, sparse columns, surrogate keys, temporary tables and many more. Essentially, all the commands that are not supported in distributed processing mode.

The most biggest annoyance (!) is case sensitivity! Ughh.. This proves that the SQL operates like API on top of delta tables, which is translated either into PySpark commands or not directly to Spark since Spark is not case-sensitive. So, the first one will work and the second statement will be gracefully terminated.

SELECT * FROM dbo.iris_data;
SELECT * FROM dbo.Iris_Data;

Functions for using different data types are supported, but there are some, like image, text. But the majority will work. And here is the mapping between the delta table format and T-SQL

(source: https://learn.microsoft.com/en-us/fabric/data-warehouse/data-types)

As well any DML statements are not supported, mainly DELETE, INSERT, UPDATE and others. Also, ALTER table (but ALTER on function, procedure will work!), column will not work! So keep in mind that DML statements will have to be done on the delta table level! Both super simple queries will be terminated since the DML statements are not supported (allowed):

DELETE FROM iris_species WHERE ID =1

UPDATE dbo.iris_species
SET species = 'Setosa'
where ID=1

Creating procedures will also work, as well as the functions. With functions, table-valued and will work just fine:

CREATE FUNCTION udfSpecies (
    @id INT
)
RETURNS TABLE
AS
RETURN
    SELECT 
        ID
        ,species
    FROM
        iris_species
    WHERE
        ID = @id;


SELECT * FROM udfSpecies(1)

What about Multi-statement table-valued functions (MSTVF)? This one will unfortunately not work, because the @return_variable is not supported for CREATE/ALTER FUNCTION.

CREATE FUNCTION udmfSpecies()
    RETURNS @data TABLE (
        sl VARCHAR(50),
        sw VARCHAR(50),
        pl VARCHAR(50),
        pw VARCHAR(50),
        species VARCHAR(50)
    )
AS
BEGIN
    INSERT INTO @data
    SELECT 
     [Sepal.Length]
     ,[Sepal.Width]
     ,[Petal.Length]
     ,[Petal.Width]
     ,[Species]
    FROM
        [dbo].[iris_data];
    RETURN;
END;


SELECT * FROM udmfSpecies

To sum it up; SQL analytics brings so many great features and capabilities to construct and write queries. DML and transactional statements are not supported, since this workspace is meant for analytics. Also optimisation and performance statements would be covered one layer below on the delta lake level and distributed processing mode.

Tomorrow we will look into Lakehouse REST API.

Complete set of code, documents, notebooks, and all of the materials will be available at the Github repository: https://github.com/tomaztk/Microsoft-Fabric

Happy Advent of 2023! 🙂

Tagged with: , , , , , ,
Posted in Fabric, Power BI
18 comments on “Advent of 2023, Day 7 – SQL commands in SQL Analytics endpoint
  1. […] Dec 07: SQL commands in SQL Analytics endpoint […]

    Like

  2. […] Dec 07: SQL commands in SQL Analytics endpoint […]

    Like

  3. […] Dec 07: SQL commands in SQL Analytics endpoint […]

    Like

  4. […] Dec 07: SQL commands in SQL Analytics endpoint […]

    Like

  5. […] Dec 07: SQL commands in SQL Analytics endpoint […]

    Like

  6. […] Dec 07: SQL commands in SQL Analytics endpoint […]

    Like

  7. […] Dec 07: SQL commands in SQL Analytics endpoint […]

    Like

  8. […] Dec 07: SQL commands in SQL Analytics endpoint […]

    Like

  9. […] Dec 07: SQL commands in SQL Analytics endpoint […]

    Like

  10. […] Dec 07: SQL commands in SQL Analytics endpoint […]

    Like

Leave a comment

Follow TomazTsql on WordPress.com
Programs I Use: SQL Search
Programs I Use: R Studio
Programs I Use: Plan Explorer
Rdeči Noski – Charity

Rdeči noski

100% of donations made here go to charity, no deductions, no fees. For CLOWNDOCTORS - encouraging more joy and happiness to children staying in hospitals (http://www.rednoses.eu/red-noses-organisations/slovenia/)

€2.00

Top SQL Server Bloggers 2018
TomazTsql

Tomaz doing BI and DEV with SQL Server and R, Python, Power BI, Azure and beyond

Discover WordPress

A daily selection of the best content published on WordPress, collected for you by humans who love to read.

Revolutions

Tomaz doing BI and DEV with SQL Server and R, Python, Power BI, Azure and beyond

Reeves Smith's SQL & BI Blog

A blog about SQL Server and the Microsoft Business Intelligence stack with some random Non-Microsoft tools thrown in for good measure.

SQL Server

for Application Developers

Business Analytics 3.0

Data Driven Business Models

SQL Database Engine Blog

Tomaz doing BI and DEV with SQL Server and R, Python, Power BI, Azure and beyond

Search Msdn

Tomaz doing BI and DEV with SQL Server and R, Python, Power BI, Azure and beyond

R-bloggers

Tomaz doing BI and DEV with SQL Server and R, Python, Power BI, Azure and beyond

Data Until I Die!

Data for Life :)

Paul Turley's SQL Server BI Blog

sharing my experiences with the Microsoft data platform, Fabric, enterprise Power BI, SQL Server BI, Data Modeling, SSAS Design, SSRS, Dashboards & Visualization since 2009

Grant Fritchey

Intimidating Databases and Code

Madhivanan's SQL blog

A modern business theme

Alessandro Alpi's Blog

DevOps could be the disease you die with, but don’t die of.

Paul te Braak

Business Intelligence Blog

Sql Insane Asylum (A Blog by Pat Wright)

Information about SQL (PostgreSQL & SQL Server) from the Asylum.

Gareth's Blog

A blog about Life, SQL & Everything ...

SQLPam's Blog

Life changes fast and this is where I occasionally take time to ponder what I have learned and experienced. A lot of focus will be on SQL and the SQL community – but life varies.

William Durkin

William Durkin a blog on SQL Server, Replication, Performance Tuning and whatever else.

$hell Your Experience !!!

As aventuras de um DBA usando o Poder do $hell

Design a site like this with WordPress.com
Get started