Hi Everyone,
I am new to DLT and am trying to run below code to create table dynamically. But I get error "AttributeError: module 'dlt' has no attribute 'table'".
code snippet:
def generate_tables(model_name😞
try:
spark.sql("select * from dlt.{0}".format(model_name))
@dlt.append_flow(target = model_name)
def append_raw():
return(spark.table("dlt.{0}".format(model_name)).where("source_datetime>=''"))
except:
@dlt.table(
name=model_name,
comment="RAW: {}".format(model_name)
)
def create_table():
tableSchema=createSchema('Meta_Data.csv',model_name)
return(spark.read.format("csv").option("delimiter","|").option("header","true").option("escape","\"").load("{0}/{1}".format(<path to file>),schema=tableSchema).withColumn("source_datetime",current_timestamp()))
import dlt
generate_tables('dlt_Raw')
when I run the generate_tables function with parameter, I get the above error.
I have the dlt module loaded via pip install