Hi everyone,
We've encountered a strange issue with Databricks Lakeflow Connect query-based ingestion from SQL Server, and I'm wondering if anyone else has experienced something similar.
We have a SQL Server table with 1,448 records and a uniqueidentifier primary key. When performing a full refresh, Databricks ingests only 364 records, but the pipeline completes successfully without any errors.
After digging into the cluster logs, I suspect the problem is related to how Databricks handles GUID ordering during snapshot partitioning.
The connector correctly identifies 1,448 distinct IDs:
-- logs
getSnapshotSplitsByNonNumericKey:
splitCount=1, totalDistinct=1448
However, the generated query applies the following filter:
-- logs
Pushed Filters: Id IS NOT NULL, (RPAD(Id, 36, ' ')) <= '38C5A9C6-D111-4182-8A7F-FFE14F608876'
The snapshot then completes with:
-- logs
numInputRows: 364
dropped: 0
What I think is happening
SQL Server compares uniqueidentifier values differently from their string representations.
My theory is that Databricks:
Retrieves the GUIDs using SQL Server's native GUID ordering.
Determines the upper boundary for the snapshot partition.
Applies that boundary using a string comparison (RPAD(Id, 36, ' ') <= ...).
Accidentally excludes records because string ordering and native GUID ordering are different.
For example, consider these two GUIDs:
38DE50FE-2AC8-46E8-91AB-EAB0A9E944B0
38C5A9C6-D111-4182-8A7F-FFE14F608876
You can reproduce the difference directly in SQL Server. Try this query:
DECLARE @guid_a uniqueidentifier = '38DE50FE-2AC8-46E8-91AB-EAB0A9E944B0';
DECLARE @guid_b uniqueidentifier = '38C5A9C6-D111-4182-8A7F-FFE14F608876';
SELECT CASE WHEN @guid_a < @guid_b THEN 'TRUE' ELSE 'FALSE' END, 'GUID'
UNION
SELECT CASE WHEN CONVERT(char(36), @guid_a) < CONVERT(char(36), @guid_b) THEN 'TRUE' ELSE 'FALSE' END, 'STR';
The result is:
TRUE GUID
FALSE STR
So the same two GUIDs produce opposite comparison results depending on whether they are compared as native uniqueidentifier values or strings.
My questions
Has anyone encountered this issue with Lakeflow Connect query-based ingestion?
Is there a way to override the automatically selected snapshot partitioning column in the pipeline configuration?
Are there any known workarounds that don't require modifying the source SQL Server tables?
What concerns me most is that the pipeline reports a successful full refresh despite missing a significant number of records. This could easily go unnoticed and lead to silently incomplete datasets.
Any insights would be appreciated. Thanks!