1

I am supposed to do incremental load and using below structure. Do the statements execute in sequence i.e. TRUNCATE is never executed before first two statements which are getting data:

@newData = Extract ... (FROM FILE STREAM)

@existingData = SELECT * FROM dbo.TableA //this is ADLA table

@allData = SELECT * FROM @newData UNION ALL SELECT * FROM @existingData

TRUNCATE TABLE dbo.TableA;

INSERT INTO dbo.TableA SELECT * FROM @allData

1 Answer 1

2

To be very clear: U-SQL scripts are not executed statement by statement. Instead it groups the DDL/DML/OUTPUT statements in order and the query expressions are just subtrees to the inserts and outputs. But first it binds the data during compilation to their names, so your SELECT from TableA will be bound to the data (kind of like a light-weight snapshot), so even if the truncate is executed before the select, you should still be able to read the data from table A (note that permission changes may impact that).

Also, if your script fails during the execution phase, you should have an atomic execution. That means if your INSERT fails, the TRUNCATE should be undone at the end.

Having said that, why don't you use INSERT incrementally and use ALTER TABLE REBUILD periodically instead of doing the above pattern that reads the full table on every insertion?

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks Michael. I suspected the same and this explains occasional data loss. May I request the code structure for atomic execution?
Not sure what you mean with requesting. You can file a feature request at aka.ms/adlfeedback. Please note that it is very unlikely that we add full ACID support, since that will negatively impact the scalability and is not really needed in analytics scenarios (read-committed snapshot isolation is normally sufficient).
I am not requesting for ACID support but seeking alternatives to achieve no data loss for the above case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.