Share via

Create a table on serverless database with specified DATA_SOURCE and FILE_FORMAT from PySpark.

Afroz Shaik 0 Reputation points
2023-09-26T16:04:20.59+00:00

Hi Community,

I was trying to create the table with specified DATA_SOURCE and FILE_FORMAT from PySpark. But I was allowed only to create something like this

spark.sql(ddlscript+") USING DELTA partitioned by("\
                                +",".join(partitionby_cols)+") TBLPROPERTIES (delta.enableChangeDataFeed = true) LOCATION '"+silver_path+"'")


what i wanted to create is something like below from pyspark, without using pyodbc:

spark.sql("CREATE EXTERNAL TABLE dbo.table(
	[col1] varchar(400),
	[col2] varchar(400),
	[col3] varchar(400),
	[col4] datetime2(7)
	)
	WITH (
	LOCATION = 'folder/folder1/table',
	DATA_SOURCE = [folder1],
	FILE_FORMAT = [delta]
	)")

Community Center | Not monitored
0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.