Skip to content

Commit e2d8229

Browse files
committed
Fix error example
1 parent 09a91d9 commit e2d8229

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

docs/sql-data-sources-jdbc.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ the following case-insensitive options:
6464
Example:<br>
6565
<code>
6666
spark.read.format("jdbc")<br>
67-
&nbsp&nbsp .option("dbtable", "(select c1, c2 from t1) as subq")<br>
68-
&nbsp&nbsp .option("partitionColumn", "subq.c1"<br>
69-
&nbsp&nbsp .load()
67+
.option("url", jdbcUrl)<br>
68+
.option("query", "select c1, c2 from t1")<br>
69+
.load()
7070
</code></li>
7171
</ol>
7272
</td>

sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCOptions.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,13 @@ class JDBCOptions(
137137
|the partition columns using the supplied subquery alias to resolve any ambiguity.
138138
|Example :
139139
|spark.read.format("jdbc")
140-
| .option("dbtable", "(select c1, c2 from t1) as subq")
141-
| .option("partitionColumn", "subq.c1"
142-
| .load()
140+
| .option("url", jdbcUrl)
141+
| .option("dbtable", "(select c1, c2 from t1) as subq")
142+
| .option("partitionColumn", "c1")
143+
| .option("lowerBound", "1")
144+
| .option("upperBound", "100")
145+
| .option("numPartitions", "3")
146+
| .load()
143147
""".stripMargin
144148
)
145149

sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,9 +1348,13 @@ class JDBCSuite extends QueryTest
13481348
|the partition columns using the supplied subquery alias to resolve any ambiguity.
13491349
|Example :
13501350
|spark.read.format("jdbc")
1351-
| .option("dbtable", "(select c1, c2 from t1) as subq")
1352-
| .option("partitionColumn", "subq.c1"
1353-
| .load()
1351+
| .option("url", jdbcUrl)
1352+
| .option("dbtable", "(select c1, c2 from t1) as subq")
1353+
| .option("partitionColumn", "c1")
1354+
| .option("lowerBound", "1")
1355+
| .option("upperBound", "100")
1356+
| .option("numPartitions", "3")
1357+
| .load()
13541358
""".stripMargin
13551359
val e5 = intercept[RuntimeException] {
13561360
sql(

0 commit comments

Comments
 (0)