Skip to content

Commit 1af09f3

Browse files
committed
[SPARK-16381] some fixes, more to come
1 parent e7def7c commit 1af09f3

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

docs/sql-programming-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ In addition to simple column references and expressions, DataFrames also have a
337337

338338
<div data-lang="r" markdown="1">
339339

340-
{% include_example untyped_transformations r/RSparkSQLExample.R %}
340+
{% include_example dataframe_operations r/RSparkSQLExample.R %}
341341

342342
For a complete list of the types of operations that can be performed on a DataFrame refer to the [API Documentation](api/R/index.html).
343343

examples/src/main/r/RSparkSQLExample.R

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,19 @@ sparkR.session()
2424
df <- read.json("examples/src/main/resources/people.json")
2525

2626
# Displays the content of the DataFrame
27+
head(df)
28+
29+
# Another method to print the first few rows and optionally truncate the printing of long values
2730
showDF(df)
2831
# $example off:create_DataFrames$
2932

3033

31-
# $example on:untyped_transformations$
34+
# $example on:dataframe_operations$
3235
# Create the DataFrame
3336
df <- read.json("examples/src/main/resources/people.json")
3437

3538
# Show the content of the DataFrame
36-
showDF(df)
39+
head(df)
3740
## age name
3841
## null Michael
3942
## 30 Andy
@@ -46,31 +49,31 @@ printSchema(df)
4649
## |-- name: string (nullable = true)
4750

4851
# Select only the "name" column
49-
showDF(select(df, "name"))
52+
head(select(df, "name"))
5053
## name
5154
## Michael
5255
## Andy
5356
## Justin
5457

5558
# Select everybody, but increment the age by 1
56-
showDF(select(df, df$name, df$age + 1))
59+
head(select(df, df$name, df$age + 1))
5760
## name (age + 1)
5861
## Michael null
5962
## Andy 31
6063
## Justin 20
6164

6265
# Select people older than 21
63-
showDF(where(df, df$age > 21))
66+
head(where(df, df$age > 21))
6467
## age name
6568
## 30 Andy
6669

6770
# Count people by age
68-
showDF(count(groupBy(df, "age")))
71+
head(count(groupBy(df, "age")))
6972
## age count
7073
## null 1
7174
## 19 1
7275
## 30 1
73-
# $example off:untyped_transformations$
76+
# $example off:dataframe_operations$
7477

7578

7679
# $example on:sql_query$

0 commit comments

Comments
 (0)