DataSQRL / sqrl

Compiler for streaming data pipelines and data microservices with configurable engines.
https://www.datasqrl.com/
76 stars 10 forks source link

Errored DISTINCT ON on proceeding line throw incorrect parser position #489

Open mbroecheler opened 5 months ago

mbroecheler commented 5 months ago

In the following script, I'm missing an = in the definition statement for AllTransactions, however, the error I get is on a different line and seamingly unrelated.

IMPORT creditcard-data.Merchant;
IMPORT creditcard-data.Assignment AS CardAssignment;
IMPORT creditcard-data.Transaction AS Transaction1;
--IMPORT creditcard.AddTransaction AS Transaction2 TIMESTAMP _source_time AS time;
IMPORT creditcard.AddChatMessage;
IMPORT time.*;

Merchant :=       DISTINCT Merchant ON merchantId ORDER BY updatedTime DESC;
CardAssignment := DISTINCT CardAssignment ON cardNo ORDER BY timestamp DESC;

AllTransactions: SELECT transactionId, cardNo, amount, merchantId, time FROM Transaction1
                   UNION ALL
                 SELECT transactionId, cardNo, amount, merchantId, time FROM Transaction2;

error message:

[WARN] Could not compile SQRL script creditcard.sqrl
in script:<schema>:

[FATAL] Encountered ";" at line 1, column 77.
Was expecting one of:
    <EOF> 
    "FETCH" ...
    "LIMIT" ...
    "NULLS" ...
    "OFFSET" ...
    "," ...

in script:<schema> [1:77]:
IMPORT creditcard-data.Merchant;
----------------------------------------------------------------------------^
henneberger commented 5 months ago

This will be resolved when we fully move to the calcite parser #494. This happens because the proceeding line is a distinct on so it treats the AllTransactions lines as order by statements. The grammar appears too greedy and didn't break on the semicolon.