You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by li...@apache.org on 2017/11/05 06:07:29 UTC
spark git commit: [SPARK-22443][SQL] add implementation of
quoteIdentifier, getTableExistsQuery and getSchemaQuery in AggregatedDialect
Repository: spark
Updated Branches:
refs/heads/master 3bba8621c -> 572284c5b
[SPARK-22443][SQL] add implementation of quoteIdentifier, getTableExistsQuery and getSchemaQuery in AggregatedDialect
…
## What changes were proposed in this pull request?
override JDBCDialects methods quoteIdentifier, getTableExistsQuery and getSchemaQuery in AggregatedDialect
## How was this patch tested?
Test the new implementation in JDBCSuite test("Aggregated dialects")
Author: Huaxin Gao <hu...@us.ibm.com>
Closes #19658 from huaxingao/spark-22443.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/572284c5
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/572284c5
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/572284c5
Branch: refs/heads/master
Commit: 572284c5b08515901267a37adef4f8e55df3780e
Parents: 3bba862
Author: Huaxin Gao <hu...@us.ibm.com>
Authored: Sat Nov 4 23:07:24 2017 -0700
Committer: gatorsmile <ga...@gmail.com>
Committed: Sat Nov 4 23:07:24 2017 -0700
----------------------------------------------------------------------
.../org/apache/spark/sql/jdbc/AggregatedDialect.scala | 12 ++++++++++++
.../scala/org/apache/spark/sql/jdbc/JDBCSuite.scala | 12 ++++++++++++
2 files changed, 24 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/572284c5/sql/core/src/main/scala/org/apache/spark/sql/jdbc/AggregatedDialect.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/jdbc/AggregatedDialect.scala b/sql/core/src/main/scala/org/apache/spark/sql/jdbc/AggregatedDialect.scala
index 1419d69..f3bfea5 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/jdbc/AggregatedDialect.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/jdbc/AggregatedDialect.scala
@@ -42,6 +42,18 @@ private class AggregatedDialect(dialects: List[JdbcDialect]) extends JdbcDialect
dialects.flatMap(_.getJDBCType(dt)).headOption
}
+ override def quoteIdentifier(colName: String): String = {
+ dialects.head.quoteIdentifier(colName)
+ }
+
+ override def getTableExistsQuery(table: String): String = {
+ dialects.head.getTableExistsQuery(table)
+ }
+
+ override def getSchemaQuery(table: String): String = {
+ dialects.head.getSchemaQuery(table)
+ }
+
override def isCascadingTruncateTable(): Option[Boolean] = {
// If any dialect claims cascading truncate, this dialect is also cascading truncate.
// Otherwise, if any dialect has unknown cascading truncate, this dialect is also unknown.
http://git-wip-us.apache.org/repos/asf/spark/blob/572284c5/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala
index 167b3e0..88a5f61 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala
@@ -740,6 +740,15 @@ class JDBCSuite extends SparkFunSuite
} else {
None
}
+ override def quoteIdentifier(colName: String): String = {
+ s"My $colName quoteIdentifier"
+ }
+ override def getTableExistsQuery(table: String): String = {
+ s"My $table Table"
+ }
+ override def getSchemaQuery(table: String): String = {
+ s"My $table Schema"
+ }
override def isCascadingTruncateTable(): Option[Boolean] = Some(true)
}, testH2Dialect))
assert(agg.canHandle("jdbc:h2:xxx"))
@@ -747,6 +756,9 @@ class JDBCSuite extends SparkFunSuite
assert(agg.getCatalystType(0, "", 1, null) === Some(LongType))
assert(agg.getCatalystType(1, "", 1, null) === Some(StringType))
assert(agg.isCascadingTruncateTable() === Some(true))
+ assert(agg.quoteIdentifier ("Dummy") === "My Dummy quoteIdentifier")
+ assert(agg.getTableExistsQuery ("Dummy") === "My Dummy Table")
+ assert(agg.getSchemaQuery ("Dummy") === "My Dummy Schema")
}
test("Aggregated dialects: isCascadingTruncateTable") {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org