cancel
Showing results for 
Search instead for 
Did you mean: 
suxinji
Employee Alumni
Employee Alumni

Overview

In this recipe, you’ll learn how to run SQL queries from SparkR. After using the read() Incorta Notebook extension function to load data in Incorta Notebook, the data is in a SparkR DataFrame. You can use sql() to write SQL queries after creating a temporary view and a new DataFrame will be created.

You can use the display() Incorta Notebook extension function to explore the data. 

Solution

# load data from incorta
df <- read("Titanic_R.Titanic_train")
# create a temporary view
createOrReplaceTempView(df, "titanic_data")
# use sql query 
df_sql <- sql("SELECT * FROM titanic_data WHERE Survived = 0 AND age <= 19")
# show data 
display(df_sql)

After running the display in a separate paragraph, the data is shown in a table. You can use different visualization tools provided by Incorta Notebook to explore and visualize the data.

Screen Shot 2022-04-05 at 4.00.41 PM.png

 

 

Best Practices Index
Best Practices

Just here to browse knowledge? This might help!

Contributors
Version history
Last update:
‎04-06-2022 10:50 AM
Updated by: