Pipelines are expected to have at least one table Error While running DLT pipeline

vignesh22
New Contributor

Error :Pipelines are expected to have at least one table defined but

no tables were found in your pipeline

 

I wrote simple code as phase 1 debug
%sql CREATE OR REFRESH STREAMING TABLE test_table AS SELECT "hello" as greeting;

 

Can u plz help what's wrong in this code ?

Pricing Tier : Premium (+ Role-based access controls) (Click to change)

Takuya-Omi
Valued Contributor III

@vignesh22 

In Delta Live Tables (DLT), magic commands (such as %sql) are not used. In a DLT pipeline, you need to write SQL code directly. Please try removing %sql and running the DLT pipeline again.

--------------------------
Takuya Omi (尾美拓哉)

RiyazAliM
Honored Contributor

Hey @vignesh22 - Adding to what @Takuya-Omi san has mentioned - the instantiation of streaming table in your definition is incorrect. You're trying to create a stream table using a batch source which will result in the DLT Analysis Exception as described below.

com.databricks.pipelines.common.errors.DLTAnalysisException: Creating a streaming table from a batch query prevents incremental loading of new data from source. Offending table: 'dev.default.test_table'.
Please use the stream() operator. Example usage:
CREATE STREAMING TABLE <target table name> ... AS SELECT ... FROM stream(<source table name>) ...

If you're only trying to test the functionality of DLT, may be create a materialized view rather than the streaming table.

https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-create-materialized-view 

Let me know if any questions! Cheers!

 

Riz