Module 'dlt' has no attribute 'table' - databricks and delta live tables
Asked Answered
J

5

7

I am new to databricks and delta live tables. I have problem with creating delta live table in python.

enter image description here

enter image description here

enter image description here

How to create delta live table from json files in filestore?

Jokjakarta answered 15/5, 2022 at 15:22 Comment(0)
S
3

It is a decorator, so I think you also need a function after. Meaning

@dlt.table(comment="your comment")
def get_bronze():
    df=spark.sql("""select * from myDb.MyRegisterdTable""")
    #If you wanna check logs:
    #print("bronze",df.take(5),"end")
    return df

In silver function then you can read it as:

@dlt.table
def get_silver():
    df = dlt.read("get_bronze")
    [..do_stuff...]
    return df

Also from your screenshots I am not sure, are you running all this as a pipeline or are you trying to run a Notebook? The latter does not work.

Schnitzler answered 18/5, 2022 at 14:29 Comment(3)
from error it's running from notebook, not pipelineChildish
Yes, I was running Notebook. I am beginner with Delta Live Tables, Databricks.. Thank you for help.Jokjakarta
You are welcome :-) And everyone is a beginner with delta live tables, it is a new thing ;-)Schnitzler
M
1

Sandro’s answer should solve your problem. For ingesting json files with live tables, you can check this article for some use cases https://medium.com/@chaobioz/create-delta-live-tables-dlt-dynamically-with-pyspark-e06a718199c8

Also if for production, better use auto loader as well.

Misdo answered 21/5, 2022 at 4:34 Comment(0)
A
0
  1. Create a Notebook with the scripts
  2. Create a Pipeline (With your Required configs).
  3. Start the Pipeline directly, don't run the notebook Delta Tables will be created directly.

You can check this process mentioned in the documentation itself. https://docs.databricks.com/workflows/delta-live-tables/delta-live-tables-quickstart.html

Read the steps just above the requirement, I guess that would help.

Angevin answered 20/9, 2022 at 6:24 Comment(0)
P
0

Use Databricks cluster, runtime above 13

Peppel answered 27/11, 2023 at 7:20 Comment(0)
E
-2

Could you try to install dlt before importing it?

%pip install dlt

Explanation answered 17/5, 2022 at 12:53 Comment(3)
The problem ist not 'dlt' modul. It says that dlt module exist but dlt.table doesn't.Aposiopesis
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Melisamelisande
Warning, the above dlt package available via pip install has nothing to do with Databricks Delta Live TablesCompellation

© 2022 - 2024 — McMap. All rights reserved.