Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
jcamilo1985
Helper III
Helper III

write table in lakehouse

Good morning

Greetings to all.

Microsoft Fabric was recently added to the organization and I have been exploring the service in order to get the most out of it.
I want to use datamart and lakehouse service, but for now I have the following question:

How can I write the table in the tables section.

 

I add the simple code that I am using, if you wish you can replicate it, it is an open government data page.

 

muestra_codigo.png

 

As you can see, I am using the R language to read the API, but for now I cannot save this table. If anyone can help me, thanks in advance.

 

Additionally, if you know of resources where I can learn to use these new resources (datamart, lakehouse, pipeline...), I would greatly appreciate it.

 

1 ACCEPTED SOLUTION
v-gchenna-msft
Community Support
Community Support

Hi @jcamilo1985  - Thanks for using Fabric Community,

As I understand you are very new to fabric and sparkR, would like to learn explore things on it. 
I am sharing few links that helps you get more insights with fabric and sparkR.

Fabric Link: It helps you understand these new resources (datamart, lakehouse, pipeline...)
Get started with Microsoft Fabric - Training | Microsoft Learn 

Spark R Link: helps to understand how to use SparkR
SparkR overview - Azure Databricks | Microsoft Learn
Tutorial: Work with SparkR SparkDataFrames on Databricks | Databricks on AWS

I was able to create a table in lakehouse using below code, attached screenshot for reference -

sparkR.png

# tableName <- "<catalog-name>.<schema-name>.<table-name>"
tableName <- "gopi_lake_house.abc"

data   <- list(
            list(1L, "Raymond", "green",  "apple"),
            list(2L, "Loretta", "purple", "grape"),
            list(3L, "Wayne",   "yellow", "banana")
          )

schema <- structType(
            structField("id",    "integer"),
            structField("name",  "string"),
            structField("color", "string"),
            structField("fruit", "string")
          )

df <- createDataFrame(
        data   = data,
        schema = schema
      )

saveAsTable(
  df        = df,
  tableName = tableName
)

# Verify that the table was successfully saved by
# displaying the table's contents.
display(sql(paste0("SELECT * FROM ", tableName)))


 Hope this helps your query. Happy Learning.!

View solution in original post

5 REPLIES 5
ajarora
Employee
Employee

If you want to use an easier no code solution for a simple data ingestion, you will find pipelines a much better choice. You can start creating a pipeline, and click on copy data, and it should be pretty straight forward to figure out the rest of the steps. If you still get stuck refer this tutorial https://learn.microsoft.com/en-us/fabric/data-factory/tutorial-end-to-end-pipeline

 

v-gchenna-msft
Community Support
Community Support

Hi @jcamilo1985  - Thanks for using Fabric Community,

As I understand you are very new to fabric and sparkR, would like to learn explore things on it. 
I am sharing few links that helps you get more insights with fabric and sparkR.

Fabric Link: It helps you understand these new resources (datamart, lakehouse, pipeline...)
Get started with Microsoft Fabric - Training | Microsoft Learn 

Spark R Link: helps to understand how to use SparkR
SparkR overview - Azure Databricks | Microsoft Learn
Tutorial: Work with SparkR SparkDataFrames on Databricks | Databricks on AWS

I was able to create a table in lakehouse using below code, attached screenshot for reference -

sparkR.png

# tableName <- "<catalog-name>.<schema-name>.<table-name>"
tableName <- "gopi_lake_house.abc"

data   <- list(
            list(1L, "Raymond", "green",  "apple"),
            list(2L, "Loretta", "purple", "grape"),
            list(3L, "Wayne",   "yellow", "banana")
          )

schema <- structType(
            structField("id",    "integer"),
            structField("name",  "string"),
            structField("color", "string"),
            structField("fruit", "string")
          )

df <- createDataFrame(
        data   = data,
        schema = schema
      )

saveAsTable(
  df        = df,
  tableName = tableName
)

# Verify that the table was successfully saved by
# displaying the table's contents.
display(sql(paste0("SELECT * FROM ", tableName)))


 Hope this helps your query. Happy Learning.!

@v-gchenna-msft 

Thank you very much for responding to the request, this solution indeed works.
Thanks for the links, now let's learn.

Hello @jcamilo1985 ,

We haven’t heard from you on the last response and was just checking back to see if your query got resolved? Otherwise, will respond back with the more details and we will try to help.

Thank you

Hi @jcamilo1985 ,

We haven’t heard from you on the last response and was just checking back to see if your query got resolved? Otherwise, will respond back with the more details and we will try to help.

Thank you

Helpful resources

Announcements
Expanding the Synapse Forums

New forum boards available in Synapse

Ask questions in Data Engineering, Data Science, Data Warehouse and General Discussion.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Update Carousel

Fabric Monthly Update - April 2024

Check out the April 2024 Fabric update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors