Skip to content
Advertisement

Spark SQL INSERTION TECHNIQUE for Result got from calculation

or insertion I’m using below code-

spark.sql("INSERT INTO countDirectorySize VALUES (`" +str(root) + "`)")

Entire code here for better understanding-

root = "/dbfs/mnt/datalake/.../"
spark.sql("INSERT INTO countDirectorySize VALUES (`" +str(root) + "`)")

This code gives error while inserting. Any help would be great.

Error:

    "cannot resolve '`/dbfs/mnt/datalake/.../`' given input columns: []; 
line 1 pos 30;n'InsertIntoTable 'UnresolvedRelation `countSize`, false, falsen+- 'UnresolvedInlineTable [col1], [List('/dbfs/mnt/datalake/.../)]n"

Advertisement

Answer

This worked- The arrangement. Just ('"____"') is all I wanted to know.

spark.sql("INSERT INTO countDirectorySize VALUES ('"+str(root)+"')")
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement