Issue with query /cardinality estimation / statistics in Synapse Serverless SQL (error code 15833, 3602)

Thomas Totter 21 Reputation points
2022-07-25T14:32:03.41+00:00

Hello,

I created several external tables in Synapse On-Demand/Serverless pool. Most of them work as expected, however i do have an issue with one external table that points to a CSV file under specific circumstances.

The table i created is: dbo.customer:
create external table [dbo].[customer]
(
[sales_org_id] nvarchar,
[debitor_id] nvarchar,
[group_id] nvarchar,
[customer_name1] nvarchar,
[customer_name2] nvarchar,
[street] nvarchar,
[zip_code] nvarchar,
[city] nvarchar,
[country] nvarchar,
[customer_group_id] nvarchar,
[customer_Group_name] nvarchar,
[branch_id] nvarchar,
[branch_text] nvarchar,
[kl] nvarchar,
[sales_group_id] nvarchar,
[role_id] nvarchar,
[customer_id] nvarchar,
[lvm] nvarchar,
[lvm2] nvarchar,
[hier_1] nvarchar,
[hier_1_name] nvarchar,
[hier_2] nvarchar,
[hier_2_name] nvarchar,
[hier_3] nvarchar,
[hier_3_name] nvarchar,
[hier_4] nvarchar,
[hier_4_name] nvarchar,
[hier_5] nvarchar,
[hier_5_name] nvarchar,
[hier_6] nvarchar,
[hier_6_name] nvarchar,
[hier_7] nvarchar,
[hier_8_name] nvarchar
)
with (data_source = [bbc_sas],LOCATION = N'customer.csv',FILE_FORMAT = [csv_comma_fr2])

When i select the data in Synapse Studio it works (apparently), even with full resultset:
224473-image.png
224475-image.png

When i do the same in SSMS i get an error:
224454-image.png
Query execution failed with error code 15833

If i execute the same statement but with top 1000 (or less) it works in SSMS too. Any number above 1000 will lead to the error.

In the SQL-Request monitoring of Synapse i sometimes see an error regarding "cardinality estimation" when selecting the whole resultset.
224511-image.png

So i tried to create statistics on that external table and doing that i also get an error:
224474-image.png
Internal error number 3602 encountered while creating statistics.

Azure Data Studio behaves the same as the SQL query in Synapse studio, meaning the full resultset query works, however the error message when trying to create statistics remains.
I get the same error message when trying to create statistics on openrowset (on the same file).

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,373 questions
Developer technologies Transact-SQL
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Thomas Totter 21 Reputation points
    2022-07-25T15:11:48.5+00:00

    I think i found the root cause of the issue meanwhile:
    The .csv file didn't quote special characters (in my case the separating comma) properly. So i recreated the .csv - used "|" as seperator this time and also made sure that FieldEscape is being used if needed. Now everything works like a charm. Strangely enough i didn't get any error messages before when selecting everything, although the csv parser must have had an issue with the old file.

    Anyway the error messages in this area could be a little more helpful.... :)

    Case closed on my part!.

    2 people found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.